1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-27 11:02:16 +01:00
unleash.unleash/src/lib/db/db-pool.ts
Gastón Fournier abe160eb7d
feat: Unleash v7 ESM migration (#9877)
We're migrating to ESM, which will allow us to import the latest
versions of our dependencies.

Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
2025-05-14 09:47:12 +02:00

28 lines
726 B
TypeScript

import type { Knex } from 'knex';
import knexpkg from 'knex';
const { knex } = knexpkg;
import type { IUnleashConfig } from '../types/option.js';
export function createDb({
db,
getLogger,
}: Pick<IUnleashConfig, 'db' | 'getLogger'>): Knex {
const logger = getLogger('db-pool.js');
return knex({
client: 'pg',
version: db.version,
connection: {
...db,
application_name: db.applicationName,
},
pool: db.pool,
searchPath: db.schema,
asyncStackTraces: true,
log: {
debug: (msg) => logger.debug(msg),
warn: (msg) => logger.warn(msg),
error: (msg) => logger.error(msg),
},
});
}