Spaces:
Running
Running
Download src/lib/auth.ts from risenetup/chess-monolith: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/risenetup/chess-monolith/resolve/main/src/lib/auth.ts
- Command line
-
hf download hf://spaces/risenetup/chess-monolith/src/lib/auth.ts
-
curl -L -o auth.ts https://huggingface.co/spaces/risenetup/chess-monolith/resolve/main/src/lib/auth.ts
1.24 kB
| import "dotenv/config"; | |
| import { betterAuth } from "better-auth"; | |
| import { drizzleAdapter } from "better-auth/adapters/drizzle"; | |
| import { db } from "../infrastructure/db/db"; | |
| import { v7 as uuidv7 } from "uuid"; | |
| import { authHooks } from "./utils/auth-hooks"; | |
| import { env } from "../config/env"; | |
| export const auth = betterAuth({ | |
| secret: env.BETTER_AUTH_SECRET, | |
| baseURL: env.BETTER_AUTH_URL, | |
| database: drizzleAdapter(db, { | |
| provider: "pg", | |
| }), | |
| emailAndPassword: { | |
| enabled: true, | |
| }, | |
| trustedOrigins: [process.env.CLIENT_URL || "http://localhost:3000"], | |
| session: { | |
| expiresIn: 60 * 60 * 24 * 7, | |
| updateAge: 60 * 60 * 24 * 7, | |
| cookieCache: { | |
| enabled: true, | |
| maxAge: 1, | |
| }, | |
| }, | |
| user: { | |
| additionalFields: { | |
| username: { | |
| type: "string", | |
| required: true, | |
| }, | |
| wins: { | |
| type: "number", | |
| defaultValue: 0, | |
| }, | |
| losses: { | |
| type: "number", | |
| defaultValue: 0, | |
| }, | |
| draws: { | |
| type: "number", | |
| defaultValue: 0, | |
| }, | |
| rating: { | |
| type: "number", | |
| defaultValue: 1000, | |
| }, | |
| }, | |
| }, | |
| hooks: authHooks, | |
| advanced: { | |
| database: { | |
| generateId: () => uuidv7(), | |
| }, | |
| }, | |
| }); | |