feat(WHE-22): ingest configured topic messages with idempotent persistence

This commit is contained in:
2026-03-05 04:32:58 +04:00
parent e72c145e3d
commit 67e9e2dee2
16 changed files with 1838 additions and 20 deletions

View File

@@ -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
}
}