UNPKG

embedded-postgres

Version:

A package to run an embedded Postgresql database right from NodeJS

55 lines (54 loc) 2.48 kB
/** * The options that are optionally specified for launching the Postgres database. */ export interface PostgresOptions { /** The location where the data should be persisted to. Defaults to: `./data/db` */ databaseDir: string; /** The port where the Postgres database should be listening. Defaults to: * `5432` */ port: number; /** The username for logging into the Postgres database. Defaults to `postgres` */ user: string; /** The password for logging into the Postgres database. Defaults to `password` */ password: string; /** The authentication method to use when authenticating against Postgres. * Defaults to `password` */ authMethod: 'scram-sha-256' | 'password' | 'md5'; /** Whether all data should be left in place when the database is shut down. * Defaults to `true`. */ persistent: boolean; /** Pass any additional flags to the initdb process. You can find all * available flags here: * https://www.postgresql.org/docs/current/app-initdb.html. Flags should be * passed as a string array, e.g. `["--debug"]` or `["--locale=en-GB"]` * * Defaults to `[]` */ initdbFlags: string[]; /** Pass any additional flags to the postgres process. You can find all * available flags here: * https://www.postgresql.org/docs/current/app-postgres.html. Flags should * be passed as a string array, e.g. `["--debug"]` or `["--locale=en-GB"]`. * * Defaults to `[]`. */ postgresFlags: string[]; /** * Postgres does not allow binaries to be run by root. In case you're * running in root-only enviroments, such as Docker containers, you may need * to create an extra user on your system in order to be able to call the binaries. * * NOTE: This WILL irreversibly modify your host system. The effects are * somewhat minor, but it's still recommend to only use this in Docker containers. * * Defaults to `false`. */ createPostgresUser: boolean; /** Pass in a custom logging handler. This will relay and console messages * that are generated by the postgres and initdb processes. Defaults to * `console.log` */ onLog: (message: string) => void; /** Pass in a custom error logging handler. This will catch and stderr * results coming in from the postgres and initdb processes. Defaults to * `console.error` */ onError: (messageOrError: string | Error | unknown) => void; }