feat: initial auth package

This commit is contained in:
Hyteq
2025-06-24 11:31:35 +03:00
parent 30bc2127a2
commit 3b4577e474
4 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import { createAuthClient } from "better-auth/react";
export const { signIn, signUp, useSession } = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL!,
});

View File

@ -0,0 +1,5 @@
// Re-export server auth
export * from "./server";
// Re-export client auth
export * from "./client";

View File

@ -0,0 +1,29 @@
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "@opencut/db";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
secret: process.env.BETTER_AUTH_SECRET!,
user: {
deleteUser: {
enabled: true,
},
},
emailAndPassword: {
enabled: true,
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
appName: "OpenCut",
trustedOrigins: ["http://localhost:3000"],
});
export type Auth = typeof auth;