aboutsummaryrefslogtreecommitdiff
path: root/apps/web/server/auth.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/server/auth.ts')
-rw-r--r--apps/web/server/auth.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/web/server/auth.ts b/apps/web/server/auth.ts
new file mode 100644
index 00000000..c4e426d4
--- /dev/null
+++ b/apps/web/server/auth.ts
@@ -0,0 +1,34 @@
+import NextAuth, { NextAuthResult } from "next-auth";
+import Google from "next-auth/providers/google";
+import { DrizzleAdapter } from "@auth/drizzle-adapter";
+import { db } from "./db";
+import { accounts, sessions, users, verificationTokens } from "./db/schema";
+
+export const {
+ handlers: { GET, POST },
+ signIn,
+ signOut,
+ auth,
+} = NextAuth({
+ secret: process.env.BACKEND_SECURITY_KEY,
+ // callbacks: {
+ // session: ({ session, token, user }) => ({
+ // ...session,
+ // user: {
+ // ...session.user,
+ // },
+ // }),
+ // },
+ adapter: DrizzleAdapter(db, {
+ usersTable: users,
+ accountsTable: accounts,
+ sessionsTable: sessions,
+ verificationTokensTable: verificationTokens,
+ }),
+ providers: [
+ Google({
+ clientId: process.env.GOOGLE_CLIENT_ID,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET,
+ }),
+ ],
+});