-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
50 lines (48 loc) · 1.54 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
/**
* File managing configuration for the application
**/
const dotenv = require('dotenv');
const fs = require('fs');
try
{
if (fs.statSync('.env'))
{
dotenv.load();
}
}
catch (e)
{
// Swallow exceptions due to no .env file
}
const defaults = {
NODE_ENV: 'development',
PORT: '5600',
ROOT_URL: 'http://localhost:6000', // base url to redirect to after steam oauth login
POSTGRES_URL: 'postgresql://postgres:postgres@localhost/yasp', // connection string for PostgreSQL
POSTGRES_TEST_URL: 'postgresql://postgres:postgres@localhost/yasp_test',
REDIS_URL: 'redis://127.0.0.1:6379/0', // connection string for Redis
REDIS_TEST_URL: 'redis://127.0.0.1:6379/1',
SESSION_SECRET: 'secret to encrypt cookies with', // string to encrypt cookies
COOKIE_DOMAIN: '',
GOAL: 5, // The cheese goal
STRIPE_SECRET: '', // for donations, in web
STRIPE_PUBLIC: '',
BRAIN_TREE_MERCHANT_ID: '',
BRAIN_TREE_PUBLIC_KEY: '',
BRAIN_TREE_PRIVATE_KEY: '',
};
// ensure that process.env has all values in defaults, but prefer the process.env value
for (const key in defaults)
{
process.env[key] = (key in process.env) ? process.env[key] : defaults[key];
}
if (process.env.NODE_ENV === 'test')
{
process.env.PORT = ''; // use service defaults
process.env.POSTGRES_URL = process.env.POSTGRES_TEST_URL;
process.env.CASSANDRA_URL = process.env.CASSANDRA_TEST_URL;
process.env.REDIS_URL = process.env.REDIS_TEST_URL;
process.env.SESSION_SECRET = 'testsecretvalue';
}
// now processes can use either process.env or config
module.exports = process.env;