11import { FetchError , $fetch } from 'ofetch'
2- import { getRandomValues } from 'uncrypto '
2+ import { getRandomValues } from 'node:crypto '
33import type { H3Event } from 'nitro/deps/h3'
4- import { eventHandler , getQuery , redirect , HTTPError , getRequestURL , setCookie , deleteCookie , getCookie } from 'nitro/deps/h3'
4+ import { defineEventHandler , getQuery , redirect , HTTPError , getRequestURL , setCookie , deleteCookie , getCookie } from 'nitro/deps/h3'
55import { withQuery } from 'ufo'
66import { defu } from 'defu'
77import type { Endpoints } from '@octokit/types'
@@ -22,7 +22,7 @@ interface RequestAccessTokenOptions {
2222 params ?: Record < string , string >
2323}
2424
25- export default eventHandler ( async ( event : H3Event ) => {
25+ export default defineEventHandler ( async ( event : H3Event ) => {
2626 const config = {
2727 clientId : process . env . GITHUB_OAUTH_CLIENT_ID ,
2828 clientSecret : process . env . GITHUB_OAUTH_CLIENT_SECRET ,
@@ -53,7 +53,6 @@ export default eventHandler(async (event: H3Event) => {
5353 if ( ! query . code ) {
5454
5555 return redirect (
56- event ,
5756 withQuery ( 'https://github.com/login/oauth/authorize' as string , {
5857 client_id : config . clientId ,
5958 redirect_uri : redirectURL ,
@@ -113,7 +112,7 @@ export default eventHandler(async (event: H3Event) => {
113112 } ,
114113 } , session . data ) )
115114
116- return redirect ( event , '/' )
115+ return redirect ( '/' )
117116} )
118117
119118async function requestAccessToken ( url : string , options : RequestAccessTokenOptions ) : Promise < RequestAccessTokenResponse > {
0 commit comments