This repository has been archived by the owner on May 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
config.js
124 lines (117 loc) · 2.81 KB
/
config.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
112
113
114
115
116
117
118
119
120
121
122
123
124
/* 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/. */
/* global require, module, process, __dirname */
const fs = require('fs');
const path = require('path');
const convict = require('convict');
const conf = convict({
/**
* Environment
*/
env: {
arg: 'node-env',
doc: 'The current node.js environment',
env: 'NODE_ENV',
format: ['dev', 'test', 'staging', 'production'],
default: 'dev',
},
git: {
commit: {
doc: 'Commit SHA when in stage/production',
format: String,
default: '',
env: 'GIT_COMMIT_SHA',
},
},
/**
* Server Properties
*/
server: {
host: {
env: 'HOST',
default: '127.0.0.1',
},
port: {
env: 'PORT',
format: 'port',
default: 10137,
},
session: {
env: 'COOKIE_SECRET',
format: String,
default: 'cookie_secret',
},
},
base_url: {
doc: 'Base URL of the application. Note: MUST end with a trailing slash',
format: String,
env: 'BASE_URL',
default: '/',
},
/**
* FxA OAuth
*/
//TODO: update with production settings
fxaOAuth: {
client_id: {
doc: 'The FxA client_id (8 bytes key encoded as hex)',
format: String,
default: '',
env: 'FXA_OAUTH_CLIENT_ID',
},
client_secret: {
doc: 'The FxA client secret (32 bytes key encoded as hex)',
format: String,
default: '',
env: 'FXA_OAUTH_CLIENT_SECRET',
},
oauth_uri: {
doc: 'The location of the FxA OAuth server.',
format: 'url',
default: 'https://127.0.0.1:9010/v1',
env: 'OAUTH_URI',
},
oauth_internal_uri: {
doc: 'The location of the FxA OAuth internal server.',
format: 'url',
default: 'https://127.0.0.1:9011/v1',
env: 'OAUTH_INTERNAL_URI',
},
redirect_uri: {
doc: 'The redirect_uri.',
format: String,
default: 'https://127.0.0.1:10137/oauth/redirect',
env: 'FXA_OAUTH_REDIRECT_URI',
},
profile_uri: {
doc: 'The FxA profile uri.',
format: 'url',
default: 'https://127.0.0.1:1111/profile/v1',
env: 'PROFILE_URI',
},
scopes: {
doc: 'The oauth server scopes',
format: String,
default: 'profile oauth',
env: 'FXA_OAUTH_SCOPES',
},
},
/**
* Logging
*/
logging: {
default: {
app: 'fxa-oauth-console',
},
},
});
var envConfig = path.join(__dirname, '..', 'config', conf.get('env') + '.json');
var files = (envConfig + ',' + process.env.CONFIG_FILES)
.split(',')
.filter(fs.existsSync);
conf.loadFile(files);
require('mozlog').config(conf.get('logging'));
process.env.NODE_ENV = conf.get('env');
conf.validate();
module.exports = conf;