mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 23:34:04 +00:00
feat(WHE-22): ingest configured topic messages with idempotent persistence
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
import postgres from 'postgres'
|
||||
import { drizzle } from 'drizzle-orm/postgres-js'
|
||||
|
||||
import { env } from '@household/config'
|
||||
export interface DbClientOptions {
|
||||
max?: number
|
||||
prepare?: boolean
|
||||
}
|
||||
|
||||
const queryClient = postgres(env.DATABASE_URL, {
|
||||
prepare: false,
|
||||
max: 5
|
||||
})
|
||||
export function createDbClient(databaseUrl: string, options: DbClientOptions = {}) {
|
||||
const queryClient = postgres(databaseUrl, {
|
||||
max: options.max ?? 5,
|
||||
prepare: options.prepare ?? false
|
||||
})
|
||||
|
||||
export const db = drizzle(queryClient)
|
||||
export { queryClient }
|
||||
const db = drizzle(queryClient)
|
||||
|
||||
return {
|
||||
db,
|
||||
queryClient
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user