feat(csms): add deployment script and database schema for user authentication

This commit is contained in:
2025-11-17 03:34:51 +08:00
parent 09c5ca1d3f
commit 86595c7639
21 changed files with 2377 additions and 16 deletions

27
apps/csms/src/lib/auth.ts Normal file
View File

@@ -0,0 +1,27 @@
import { betterAuth } from 'better-auth'
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { useDrizzle } from './db.js'
import * as schema from '@/db/schema.ts'
import { bearer, jwt, username } from 'better-auth/plugins'
export const auth = betterAuth({
database: drizzleAdapter(useDrizzle(), {
provider: 'pg',
schema: {
...schema,
},
}),
user: {
additionalFields: {
role: {
type: 'string',
defaultValue: 'user',
input: false,
},
},
},
emailAndPassword: {
enabled: true,
},
plugins: [username(), bearer(), jwt()],
})