diff options
| author | Dhravya <[email protected]> | 2024-02-23 16:04:49 -0700 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-02-23 16:04:49 -0700 |
| commit | aa1b57bbcd99da4c6d68c145f7c07ea7bd35c8dc (patch) | |
| tree | f5ab247b154a21bbebbe56cca0d7f3397219b7c3 /apps/anycontext-front/src/server/auth.ts | |
| parent | hide bun lockfile (diff) | |
| download | supermemory-aa1b57bbcd99da4c6d68c145f7c07ea7bd35c8dc.tar.xz supermemory-aa1b57bbcd99da4c6d68c145f7c07ea7bd35c8dc.zip | |
chaos
Diffstat (limited to 'apps/anycontext-front/src/server/auth.ts')
| -rw-r--r-- | apps/anycontext-front/src/server/auth.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/anycontext-front/src/server/auth.ts b/apps/anycontext-front/src/server/auth.ts new file mode 100644 index 00000000..3b8d749e --- /dev/null +++ b/apps/anycontext-front/src/server/auth.ts @@ -0,0 +1,37 @@ +import { env } from "@/env"; +import { DrizzleAdapter } from "@auth/drizzle-adapter"; +import NextAuth, { DefaultSession } from "next-auth"; +import { Adapter } from "next-auth/adapters"; +import Google from "next-auth/providers/google"; +import { db } from "./db"; +import { createTable } from "./db/schema"; + +export const { + handlers: { GET, POST }, + auth, +} = NextAuth({ + secret: env.NEXTAUTH_SECRET, + callbacks: { + session: ({session, token}) => ({ + ...session, + user: { + ...session.user, + id: token.id as string, + token + }, + }) + }, + adapter: DrizzleAdapter(db, createTable) as Adapter, + providers: [ + Google({ + clientId: env.GOOGLE_CLIENT_ID, + clientSecret: env.GOOGLE_CLIENT_SECRET, + authorization: { + params: { + prompt: "consent", + response_type: "code", + }, + }, + }), + ], +}); |