ts-postgres
Version:
PostgreSQL client in TypeScript
20 lines • 923 B
JavaScript
import { userInfo } from 'node:os';
function secToMsec(value) {
if (typeof value === 'number' && !isNaN(value)) {
return value * 1000;
}
}
export class Defaults {
constructor(env, host = env.PGHOST || 'localhost', port = parseInt(env.PGPORT, 10) || 5432, user = env.PGUSER || userInfo().username, database = env.PGDATABASE, password = env.PGPASSWORD, preparedStatementPrefix = 'tsp_', sslMode = env.PGSSLMODE, connectionTimeout = secToMsec(parseInt(env.PGCONNECT_TIMEOUT, 10)), clientEncoding = env.PGCLIENTENCODING) {
this.host = host;
this.port = port;
this.user = user;
this.database = database;
this.password = password;
this.preparedStatementPrefix = preparedStatementPrefix;
this.sslMode = sslMode;
this.connectionTimeout = connectionTimeout;
this.clientEncoding = clientEncoding;
}
}
//# sourceMappingURL=defaults.js.map