/
index.ts
94 lines (89 loc) · 2.51 KB
/
index.ts
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import convict from 'convict';
import fs from 'fs';
import path from 'path';
const conf = convict({
authHeader: {
default: 'oidc-claim-id-token-email',
doc: 'Authentication header that should be logged for the user',
env: 'AUTH_HEADER',
format: String,
},
authdbUrl: {
default: 'http://localhost:8000',
doc: 'fxa-auth-db-mysql url',
env: 'AUTHDB_URL',
format: String,
},
env: {
default: 'production',
doc: 'The current node.js environment',
env: 'NODE_ENV',
format: ['development', 'stage', 'production'],
},
listen: {
host: {
default: '127.0.0.1',
doc: 'The ip address the server should bind',
env: 'IP_ADDRESS',
format: 'ipaddress',
},
port: {
default: 7100,
doc: 'The port the server should bind',
env: 'PORT',
format: 'port',
},
publicUrl: {
default: 'http://127.0.0.1:3031',
env: 'PUBLIC_URL',
format: 'url',
},
},
logging: {
app: { default: 'fxa-support-panel' },
fmt: {
default: 'heka',
env: 'LOGGING_FORMAT',
format: ['heka', 'pretty'],
},
level: {
default: 'info',
env: 'LOG_LEVEL',
},
routes: {
enabled: {
default: true,
doc: 'Enable route logging. Set to false to trimming CI logs.',
env: 'ENABLE_ROUTE_LOGGING',
},
format: {
default: 'default_fxa',
format: ['default_fxa', 'dev_fxa', 'default', 'dev', 'short', 'tiny'],
},
},
},
security: {
csp: {
frameAncestors: {
default: 'none',
doc:
'https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors',
env: 'CSP_FRAME_ANCESTORS',
},
},
},
});
// handle configuration files. you can specify a CSV list of configuration
// files to process, which will be overlayed in order, in the CONFIG_FILES
// environment variable.
// Need to move two dirs up as we're in the compiled directory now
const configDir = path.dirname(path.dirname(__dirname));
let envConfig = path.join(configDir, 'config', `${conf.get('env')}.json`);
envConfig = `${envConfig},${process.env.CONFIG_FILES || ''}`;
const files = envConfig.split(',').filter(fs.existsSync);
conf.loadFile(files);
conf.validate({ allowed: 'strict' });
export default conf;