mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 09:01:19 +00:00
feat(backend): add DB persistence layer (#79)
* feat(backend): add DB persistence layer Replace raw pg Pool with Drizzle ORM backed by Bun.sql. Add per-user source configuration table (user_sources). Migrate Better Auth to drizzle-adapter. Add AES-256-GCM credential encryption. Co-authored-by: Ona <no-reply@ona.com> * fix(backend): set updatedAt explicitly in all mutations onConflictDoUpdate bypasses Drizzle's $onUpdate hook. Set updatedAt explicitly in all mutation methods. Co-authored-by: Ona <no-reply@ona.com> * fix(backend): add composite index on user_sources Add (user_id, enabled) index for the enabled() query path. Co-authored-by: Ona <no-reply@ona.com> --------- Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
18
apps/aelis-backend/auth.ts
Normal file
18
apps/aelis-backend/auth.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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"
|
||||
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,
|
||||
},
|
||||
})
|
||||
|
||||
export default auth
|
||||
Reference in New Issue
Block a user