forked from ngageoint/mage-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.js
66 lines (54 loc) · 2.02 KB
/
env.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
var util = require('util');
var environment = {};
environment.port = process.env.PORT || 4242;
environment.address = process.env.ADDRESS || "0.0.0.0";
var mongoConfig = {
// username: 'changeme',
// password: 'changeme',
// ssl: true,
scheme: 'mongodb',
host: "localhost",
port: 27017,
db: "magedb",
poolSize: 5
};
var credentials = (mongoConfig.username || mongoConfig.password) ? util.format('%s:%s@', mongoConfig.username, mongoConfig.password) : '';
environment.mongo = {
uri: mongoConfig.scheme + '://' + credentials + mongoConfig.host + ':' + mongoConfig.port + '/' + mongoConfig.db + "?" + util.format('ssl=%s', mongoConfig.ssl),
scheme: mongoConfig.scheme,
host: mongoConfig.host,
port: mongoConfig.port,
db: mongoConfig.db,
ssl: mongoConfig.ssl,
poolSize: mongoConfig.poolSize
};
var serverOptions = {
poolSize: mongoConfig.poolSize
};
// SSL configuration
// Comment out as nessecary to setup ssl between MAGE application MongoDB server
// Refer to the nodejs mongo driver docs for more information about these options
// http://mongodb.github.io/node-mongodb-native/2.0/tutorials/enterprise_features/
// You will also need to setup SSL on the mongodb side: https://docs.mongodb.com/v3.0/tutorial/configure-ssl/
// 2-way ssl configuration with x509 certificate
// environment.mongo.options = {
// server: serverOptions,
// user: '',
// auth: {
// authdb: '$external' ,
// authMechanism: 'MONGODB-X509'
// }
// };
// serverOptions.ssl = true;
// serverOptions.sslValidate = false;
// serverOptions.sslCA = fs.readFileSync('/etc/ssl/mongodb-cert.crt');
// serverOptions.sslKey = fs.readFileSync('/etc/ssl/mongodb.pem');
// serverOptions.sslCert = fs.readFileSync('/etc/ssl/mongodb-cert.crt');
environment.mongo.options = {
server: serverOptions
};
environment.userBaseDirectory = '/var/lib/mage/users';
environment.iconBaseDirectory = '/var/lib/mage/icons';
environment.attachmentBaseDirectory = '/var/lib/mage/attachments';
environment.tokenExpiration = 28800;
module.exports = environment;