Skip to content

Commit

Permalink
fix(ci): format error
Browse files Browse the repository at this point in the history
  • Loading branch information
tiesen243 committed Jan 16, 2025
1 parent eff6d92 commit 92c0ac1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/web/app/api/auth/[...auth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const GET = async (

if (!isCallback) {
const { url, state } = authProvider.getOAuthUrl()
; (await cookies()).set('oauth_state', `${state}`)
;(await cookies()).set('oauth_state', `${state}`)

return NextResponse.redirect(new URL(`${url}`, nextUrl))
}
Expand All @@ -31,7 +31,7 @@ export const GET = async (
const code = nextUrl.searchParams.get('code') ?? ''
const state = nextUrl.searchParams.get('state') ?? ''
const storedState = req.cookies.get('oauth_state')?.value ?? ''
; (await cookies()).delete('oauth_state')
;(await cookies()).delete('oauth_state')

if (!code || !state || state !== storedState) throw new Error('Invalid state')

Expand Down
2 changes: 1 addition & 1 deletion apps/web/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createEnv } from '@t3-oss/env-nextjs'
import { vercel } from '@t3-oss/env-nextjs/presets'
import { z } from 'zod'

import { authEnv } from '@yuki/auth/env'
import { env as authEnv } from '@yuki/auth/env'

export const env = createEnv({
extends: [vercel(), authEnv],
Expand Down
3 changes: 1 addition & 2 deletions apps/web/lib/auth/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
invalidateSession,
validateSessionToken,
} from '@yuki/auth'
import { authEnv } from '@yuki/auth/env'

import { env } from '@/env'

Expand All @@ -28,7 +27,7 @@ export const signIn = async (userId: string) => {
;(await cookies()).set(KEY, token, {
httpOnly: true,
path: '/',
secure: authEnv.NODE_ENV === 'production',
secure: env.NODE_ENV === 'production',
sameSite: 'lax',
expires: session.expiresAt,
})
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"types": "./dist/src/index.d.ts",
"default": "./src/index.ts"
},
"./oauth": {
"types": "./dist/oauth.d.ts",
"types": "./dist/src/oauth.d.ts",
"default": "./src/oauth.ts"
},
"./env": {
"types": "./dist/env.d.ts",
"types": "./dist/src/env.d.ts",
"default": "./src/env.ts"
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createEnv } from '@t3-oss/env-nextjs'
import { z } from 'zod'

export const authEnv = createEnv({
export const env = createEnv({
server: {
NODE_ENV: z.enum(['development', 'production']).optional(),
DISCORD_ID: z.string().min(1),
Expand Down
16 changes: 6 additions & 10 deletions packages/auth/src/oauth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Discord, generateState, GitHub } from 'arctic'

import { authEnv } from '@yuki/auth/env'
import { env } from '@yuki/auth/env'
import { db } from '@yuki/db'

export class OAuth {
Expand All @@ -15,16 +15,12 @@ export class OAuth {
switch (provider) {
case 'discord':
this.name = 'discord'
this.provider = new Discord(
authEnv.DISCORD_ID,
authEnv.DISCORD_SECRET,
callback_url,
)
this.provider = new Discord(env.DISCORD_ID, env.DISCORD_SECRET, callback_url)
this.scopes = ['identify', 'email']
break
case 'github':
this.name = 'github'
this.provider = new GitHub(authEnv.GITHUB_ID, authEnv.GITHUB_SECRET, callback_url)
this.provider = new GitHub(env.GITHUB_ID, env.GITHUB_SECRET, callback_url)
this.scopes = ['user:email']
break
default:
Expand All @@ -38,9 +34,9 @@ export class OAuth {
const url =
this.provider.createAuthorizationURL.length === 3
? // @ts-expect-error - This is a hack to make the types work
this.provider.createAuthorizationURL(state, null, this.scopes)
this.provider.createAuthorizationURL(state, null, this.scopes)
: // @ts-expect-error - This is a hack to make the types work
this.provider.createAuthorizationURL(state, this.scopes)
this.provider.createAuthorizationURL(state, this.scopes)

return { url, state }
}
Expand All @@ -50,7 +46,7 @@ export class OAuth {
this.provider.validateAuthorizationCode.length == 2
? await this.provider.validateAuthorizationCode(code, '')
: // @ts-expect-error - This is a hack to make the types work
await this.provider.validateAuthorizationCode(code)
await this.provider.validateAuthorizationCode(code)

switch (this.name) {
case 'discord':
Expand Down

0 comments on commit 92c0ac1

Please sign in to comment.