-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathindex.js
111 lines (106 loc) · 2.35 KB
/
index.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
const convict = require('convict');
const convict_format_with_validator = require('convict-format-with-validator');
const fs = require('fs');
const path = require('path');
convict.addFormats(convict_format_with_validator);
const config = convict({
env: {
doc: 'The application environment.',
format: ['development', 'test', 'production'],
default: 'development',
env: 'NODE_ENV',
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS',
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 3000,
env: 'PORT',
},
pino: {
level: {
doc: 'Pino log level',
format: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],
default: 'info',
env: 'PINO_LEVEL',
},
},
db: {
debug: {
doc: 'Debug database queries',
format: Boolean,
default: false,
env: 'DB_DEBUG',
},
client: 'pg',
connection: {
host: {
doc: 'Database host name/IP',
format: '*',
default: '127.0.0.1',
env: 'DB_HOST',
},
port: {
doc: 'Database port',
format: 'port',
default: 5432,
env: 'DB_PORT',
},
database: {
doc: 'Database name',
format: String,
default: null,
env: 'DB_NAME',
},
user: {
doc: 'Database user',
format: String,
default: null,
env: 'DB_USER',
},
password: {
doc: 'Database password',
format: String,
default: null,
sensitive: true,
env: 'DB_PASSWORD',
},
},
pool: {
min: 2,
max: 10,
},
migrations: {
tableName: 'knex_migrations',
directory: path.resolve(__dirname, '../db/migrations'),
},
seeds: {
directory: path.resolve(__dirname, '../db/seeds'),
},
},
secret: {
doc: 'JWT secret',
format: String,
default: null,
sensitive: true,
env: 'SECRET',
},
ci: {
doc: `Flag indicating whether we're running on a CI server`,
format: Boolean,
default: false,
env: 'CI',
},
});
const configFilePath = path.join(__dirname, `${config.get('env')}.json`);
if (fs.existsSync(configFilePath)) {
config.loadFile(configFilePath);
}
config.validate({allowed: 'strict'});
module.exports = config;