mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
24 lines
676 B
TypeScript
24 lines
676 B
TypeScript
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
import pg from 'pg';
|
|
import { config } from '../common/config';
|
|
import * as schema from '../databases/postgres/tables';
|
|
|
|
// create the connection
|
|
export const pool = new pg.Pool({
|
|
user: config.postgres.user,
|
|
password: config.postgres.password,
|
|
host: config.postgres.host,
|
|
port: Number(config.postgres.port).valueOf(),
|
|
database: config.postgres.database,
|
|
ssl: config.postgres.host !== 'localhost',
|
|
max: config.postgres.migrating || config.postgres.seeding ? 1 : undefined,
|
|
});
|
|
|
|
export const db = drizzle({
|
|
client: pool,
|
|
casing: 'snake_case',
|
|
schema,
|
|
logger: !config.isProduction,
|
|
});
|
|
|
|
export type db = typeof db;
|