Initial commit: Angular frontend and Expressjs backend
This commit is contained in:
9
worklenz-backend/src/config/db-config.ts
Normal file
9
worklenz-backend/src/config/db-config.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default {
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
host: process.env.DB_HOST,
|
||||
port: +(process.env.DB_PORT as string),
|
||||
max: +(process.env.DB_MAX_CLIENTS as string),
|
||||
idleTimeoutMillis: 30000,
|
||||
};
|
||||
15
worklenz-backend/src/config/db.ts
Normal file
15
worklenz-backend/src/config/db.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import pgModule, {QueryResult} from "pg";
|
||||
import dbConfig from "./db-config";
|
||||
|
||||
const pg = (process.env.USE_PG_NATIVE === "true" && pgModule.native) ? pgModule.native : pgModule;
|
||||
const pool = new pg.Pool(dbConfig);
|
||||
|
||||
pool.on("error", (err: Error) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("pg idle client error", err, err.message, err.stack);
|
||||
});
|
||||
|
||||
export default {
|
||||
pool,
|
||||
query: (text: string, params?: unknown[]) => pool.query(text, params) as Promise<QueryResult<any>>,
|
||||
};
|
||||
Reference in New Issue
Block a user