2026-03-16 01:30:02 +00:00
|
|
|
// Used by Better Auth CLI for schema generation.
|
|
|
|
|
// Run: bunx --bun auth@latest generate --config auth.ts --output src/db/auth-schema.ts
|
|
|
|
|
import { betterAuth } from "better-auth"
|
|
|
|
|
import { drizzleAdapter } from "better-auth/adapters/drizzle"
|
2026-03-16 02:00:53 +00:00
|
|
|
import { admin } from "better-auth/plugins"
|
2026-03-16 01:30:02 +00:00
|
|
|
import { SQL } from "bun"
|
|
|
|
|
import { drizzle } from "drizzle-orm/bun-sql"
|
|
|
|
|
|
|
|
|
|
const client = new SQL({ url: process.env.DATABASE_URL })
|
|
|
|
|
const db = drizzle({ client })
|
|
|
|
|
|
|
|
|
|
export const auth = betterAuth({
|
|
|
|
|
database: drizzleAdapter(db, { provider: "pg" }),
|
|
|
|
|
emailAndPassword: {
|
|
|
|
|
enabled: true,
|
|
|
|
|
},
|
2026-03-16 02:00:53 +00:00
|
|
|
plugins: [admin()],
|
2026-03-16 01:30:02 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default auth
|