39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { db } from "@zendegi/db";
|
|
import * as schema from "@zendegi/db/schema/auth";
|
|
import { env } from "@zendegi/env/server";
|
|
import { betterAuth } from "better-auth";
|
|
import { anonymous, jwt } from "better-auth/plugins";
|
|
import { oauthProvider } from "@better-auth/oauth-provider";
|
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
import { tanstackStartCookies } from "better-auth/tanstack-start";
|
|
|
|
export const auth = betterAuth({
|
|
database: drizzleAdapter(db, {
|
|
provider: "pg",
|
|
|
|
schema: schema,
|
|
}),
|
|
trustedOrigins: [env.CORS_ORIGIN],
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
},
|
|
disabledPaths: ["/token"],
|
|
plugins: [
|
|
tanstackStartCookies(),
|
|
anonymous(),
|
|
jwt(),
|
|
oauthProvider({
|
|
loginPage: "/login",
|
|
consentPage: "/consent",
|
|
allowDynamicClientRegistration: true,
|
|
allowUnauthenticatedClientRegistration: true,
|
|
validAudiences: [env.BETTER_AUTH_URL, new URL(env.BETTER_AUTH_URL).href],
|
|
}),
|
|
],
|
|
advanced: {
|
|
database: {
|
|
generateId: "uuid",
|
|
},
|
|
},
|
|
});
|