UNPKG

@vinka/repo

Version:

Database and repo utilities

63 lines (53 loc) 1.4 kB
import { Pool, PoolConfig } from 'pg'; import { Model, Options as SequelizeOptions, Sequelize } from 'sequelize'; import { Umzug, UmzugOptions } from 'umzug'; export type PoolConstructor = new (config: PoolConfig) => Pool; export type SequelizeConstructor = new ( db: string, user: string, pass: string, options: SequelizeOptions, ) => Sequelize; export type UmzugConstructor = new (config: UmzugOptions) => Umzug; /** * Configuration for a database and ORM. */ export interface DbConfig { /** * The name of the database to connect to. */ db: string; /** * A "master" database, assumed to exist on the database server, which is used to create other databases. */ masterDb: string; /** * Sequelize options. * * Most importantly: * * - options.host * - options.port */ options: SequelizeOptions; /** * The password for the database user. */ pass: string; /** * Whether to use TLS/SSL with the postgres driver and sequelize. */ ssl: boolean; /** * The username for the database user. */ user: string; } export type ModelMap = { [name: string]: Model<any, any>; } & { init: (sequelize: Sequelize) => void }; export interface Logger { debug: (...args: any) => void; error: (...args: any) => void; info: (...args: any) => void; }