-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathknexfile.ts
More file actions
60 lines (55 loc) · 1.37 KB
/
Copy pathknexfile.ts
File metadata and controls
60 lines (55 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require('dotenv-safe').config();
require('ts-node/register');
const fs = require('fs');
const path = require('path');
const pg = require('pg');
const CWD = process.cwd();
const migrations = path.join(CWD, 'src', 'server', 'db', 'migrations');
const seeds = path.join(CWD, 'src', 'server', 'db', 'seeds');
// for DEV/PROD values below are determined by docker config
// for migrating/seeding a local DB, change below values to *_LOCAL
// also, check notes in .env file, you might need to change the host
const DB = process.env.DB as string;
const DB_HOST = process.env.DB_HOST as string;
const DB_USER = process.env.DB_USER as string;
const DB_PORT = process.env.DB_PORT as string;
const DB_PW = process.env.DB_PW as string;
const sharedConfig = {
client: 'pg',
debug: false,
version: '11',
migrations: {
directory: migrations,
},
pool: {
min: 0,
max: 47,
},
seeds: {
directory: seeds,
},
connection: {
connectTimeout: 10000,
host: DB_HOST,
user: DB_USER,
password: DB_PW,
port: DB_PORT,
database: DB,
},
};
if (process.env.NODE_ENV === 'production') {
pg.defaults.ssl = true;
// @ts-ignore
sharedConfig.connection.ssl = {
ca : fs.readFileSync(path.join(CWD, 'certs', 'postgres.crt')),
rejectUnauthorized: true,
};
}
module.exports = {
development: {
...sharedConfig,
},
production: {
...sharedConfig,
},
};