28 lines
478 B
TypeScript
28 lines
478 B
TypeScript
import { SubscriptionTable } from "./subscription"
|
|
import pg from "pg"
|
|
const { Pool } = pg
|
|
|
|
export interface Database {
|
|
subscription: SubscriptionTable
|
|
}
|
|
|
|
import { Kysely, PostgresDialect } from "kysely"
|
|
import settings from "./settings"
|
|
|
|
const dialect = new PostgresDialect({
|
|
pool: new Pool({
|
|
...settings,
|
|
max: 10,
|
|
}),
|
|
})
|
|
|
|
export let db = new Kysely<Database>({
|
|
dialect,
|
|
})
|
|
|
|
export function resetDbInstance() {
|
|
db = new Kysely<Database>({
|
|
dialect,
|
|
})
|
|
}
|