-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.js
108 lines (104 loc) · 4.62 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
const fs = require('fs');
const ini = require('ini');
const {
oauth,
db,
api,
webhooks,
mail,
http = {},
} = ini.parse(fs.readFileSync('./conf/env.ini', 'utf-8'));
const dev = process.env.NODE_ENV === 'development';
const _api = dev ? api.dev : api.prod;
const backend = {
key: process.env.API_KEY || _api.key,
schema: process.env.API_SCHEMA || _api.schema,
host: process.env.API_HOST || _api.host,
port: process.env.API_PORT || _api.port,
path: process.env.API_PATH || _api.path,
};
module.exports = {
PORT: process.env.PORT || 3000,
oauth: {
github: {
clientID: process.env.GITHUB_CLIENT_ID || oauth.github.client || 'unset',
clientSecret: process.env.GITHUB_CLIENT_SECRET || oauth.github.secret || 'unset',
callbackURL: process.env.GITHUB_CALLBACK_URL || oauth.github.callback || 'unset',
scope: process.env.GITHUB_SCOPE || oauth.github.scope,
},
linkedin: {
clientID: process.env.LINKEDIN_CLIENT_ID || oauth.linkedin.client || 'unset',
clientSecret: process.env.LINKEDIN_CLIENT_SECRET || oauth.linkedin.secret || 'unset',
callbackURL: process.env.LINKEDIN_CALLBACK_URL || oauth.linkedin.callback || 'unset',
scope: process.env.LINKEDIN_SCOPE || oauth.linkedin.scope,
},
orcid: {
clientID: process.env.ORCID_CLIENT_ID || oauth.orcid.client || 'unset',
clientSecret: process.env.ORCID_CLIENT_SECRET || oauth.orcid.secret || 'unset',
callbackURL: process.env.ORCID_CALLBACK_URL || oauth.orcid.callback || 'unset',
},
mpds: {
authorizationURL: process.env.MPDS_AUTH_URL || oauth.mpds.authorize_url || 'unset',
tokenURL: process.env.MPDS_ACCESS_TOKEN_URL || oauth.mpds.access_token_url || 'unset',
clientID: process.env.MPDS_CLIENT_ID || oauth.mpds.client || 'unset',
clientSecret: process.env.MPDS_CLIENT_SECRET || oauth.mpds.secret || 'unset',
callbackURL: process.env.MPDS_CALLBACK_URL || oauth.mpds.callback || 'unset',
userProfileURL:
process.env.MPDS_USER_PROFILE_URL || oauth.mpds.user_profile_url || 'unset',
},
microsoft: {
authorizationURL:
process.env.MICROSOFT_AUTH_URL || oauth.microsoft.authorize_url || 'unset',
tokenURL:
process.env.MICROSOFT_ACCESS_TOKEN_URL ||
oauth.microsoft.access_token_url ||
'unset',
clientID: process.env.MICROSOFT_CLIENT_ID || oauth.microsoft.client || 'unset',
clientSecret: process.env.MICROSOFT_CLIENT_SECRET || oauth.microsoft.secret || 'unset',
callbackURL: process.env.MICROSOFT_CALLBACK_URL || oauth.microsoft.callback || 'unset',
userProfileURL:
process.env.MICROSOFT_USER_PROFILE_URL ||
oauth.microsoft.user_profile_url ||
'unset',
scope: process.env.MICROSOFT_SCOPE || oauth.microsoft.scope,
},
dummy: {
authorizationURL: process.env.DUMMY_AUTH_URL || oauth.dummy.authorize_url || 'unset',
tokenURL: process.env.DUMMY_ACCESS_TOKEN_URL || oauth.dummy.access_token_url || 'unset',
clientID: process.env.DUMMY_CLIENT_ID || oauth.dummy.client || 'unset',
clientSecret: process.env.DUMMY_CLIENT_SECRET || oauth.dummy.secret || 'unset',
callbackURL: process.env.DUMMY_CALLBACK_URL || oauth.dummy.callback || 'unset',
},
},
db: {
client: 'pg',
connection: {
database: process.env.PG_NAME || db.database,
host: process.env.PG_HOST || db.host,
port: process.env.PG_PORT || db.port,
user: process.env.PG_USER || db.user,
password: process.env.PG_PASSWORD || db.password,
},
tprefix: process.env.PG_TABLE_PREFIX || db.tprefix,
pool: { min: 0, max: 7 },
},
backend: {
...backend,
baseURL: `${backend.schema}://${backend.host}:${backend.port}${backend.path}`,
},
webhooks: {
calc_update: process.env.WEBHOOK_CALCULATON_UPDATE || webhooks.calc_update,
},
mail: {
host: process.env.MAIL_HOST || mail.host,
port: process.env.MAIL_PORT || mail.port,
user: process.env.MAIL_USER || mail.user,
pass: process.env.MAIL_PASSWORD || mail.pass,
from: process.env.MAIL_FROM || mail.from,
},
http: {
trust_proxy: process.env.TRUST_PROXY || http.trust_proxy || false,
force_https: process.env.FORCE_HTTPS || http.force_https || false,
},
dev,
};