import pg from "pg"
import { Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely"
import type { DB } from "../../db/src"
const { Pool } = pg
const globaldb = global as unknown as { db: Kysely<DB> }
export const db =
globaldb.db ||
new Kysely<DB>({
dialect: new PostgresDialect({ pool: new Pool({ connectionString: process.env.DATABASE_URL }) }),
plugins: [new ParseJSONResultsPlugin()],
})
if (process.env.NODE_ENV !== "production") {
globaldb.db = db
}
import pg from "pg"
import { Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely"
import type { DB } from "../../db/src"
const { Pool } = pg
const globaldb = global as unknown as { db: Kysely<DB> }
export const db =
globaldb.db ||
new Kysely<DB>({
dialect: new PostgresDialect({ pool: new Pool({ connectionString: process.env.DATABASE_URL }) }),
plugins: [new ParseJSONResultsPlugin()],
})
if (process.env.NODE_ENV !== "production") {
globaldb.db = db
}