You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
887 B
TypeScript

import { DrizzlePostgreSQLAdapter } from '@lucia-auth/adapter-drizzle'
import { db } from '$lib/db'
import { session, user } from '$lib/db/schema'
import { type User } from '$lib/db/types'
import { Lucia } from 'lucia'
import { Google } from 'arctic'
import { env } from '$env/dynamic/private'
declare module 'lucia' {
interface Register {
Lucia: typeof lucia
UserId: string
DatabaseUserAttributes: DatabaseUserAttributes
}
}
interface DatabaseUserAttributes extends Omit<User, 'password'> {}
const adapter = new DrizzlePostgreSQLAdapter(db, session, user)
export const lucia = new Lucia(adapter, {
getUserAttributes: (attributes) => {
return {
...attributes,
}
},
})
export const google = new Google(
env.PRIVATE_GOOGLE_CLIENT_ID,
env.PRIVATE_GOOGLE_CLIENT_SECRET,
(env.APP_ENV === 'prod' ? env.ORIGIN : 'http://localhost:5173') +
'/login/google/callback',
)