Built motion from commit 57199c8.|0.0.38
[motion.git] / server / config / environment / index.js
1 'use strict';
2
3 var path = require('path');
4 var _ = require('lodash');
5
6 function requiredProcessEnv(name) {
7   if (!process.env[name]) {
8     throw new Error('You must set the ' + name + ' environment variable');
9   }
10   return process.env[name];
11 }
12
13 // All configurations will extend these options
14 // ============================================
15 var all = {
16   env: process.env.NODE_ENV,
17
18   // Server uuid
19   uuid: exec('dmidecode --string system-uuid', {
20     silent: true
21   }).output.replace(/\r?\n|\r/g, ""),
22
23   // Root path of server
24   root: path.normalize(__dirname + '/../../..'),
25
26   // Root path of moh
27   moh: path.normalize(__dirname + '/../../..' + '/server/files/moh'),
28
29   // Root path of saved reports
30   reports: path.normalize(__dirname + '/../../..' + '/server/files/reports/'),
31
32   // Root path of fonts
33   fonts: path.normalize(__dirname + '/../../..' + '/server/utils/fonts/'),
34
35   // Root path of moh
36   originalSounds: path.normalize(__dirname + '/../../..' + '/server/files/sounds/original'),
37
38   // Root path of moh
39   convertedSounds: path.normalize(__dirname + '/../../..' + '/server/files/sounds/converted'),
40
41   // Server port
42   port: process.env.PORT || 9000,
43
44   // Server ip
45   ip: process.env.IP || 'localhost',
46
47   // Should we populate the DB with sample data?
48   seedDB: false,
49
50   // Secret for session, you will want to change this and make it an environment variable
51   session: {
52     name: 'xcally-motion',
53     secret: 'xcally-motion-session-secret',
54     cookie: {
55       path: '/',
56       httpOnly: true,
57       // If secure is set to true then it will cause the cookie to be set
58       // only when SSL-enabled (HTTPS) is used, and otherwise it won't
59       // set a cookie. 'true' is recommended yet it requires the above
60       // mentioned pre-requisite.
61       secure: false,
62       // Only set the maxAge to null if the cookie shouldn't be expired
63       // at all. The cookie will expunge when the browser is closed.
64       maxAge: null
65     }
66   },
67
68   // List of user roles
69   userRoles: ['guest', 'user', 'admin'],
70
71   facebook: {
72     clientID: process.env.FACEBOOK_ID || 'id',
73     clientSecret: process.env.FACEBOOK_SECRET || 'secret',
74     callbackURL: (process.env.DOMAIN || '') + '/auth/facebook/callback'
75   },
76
77   twitter: {
78     clientID: process.env.TWITTER_ID || 'id',
79     clientSecret: process.env.TWITTER_SECRET || 'secret',
80     callbackURL: (process.env.DOMAIN || '') + '/auth/twitter/callback'
81   },
82
83   google: {
84     clientID: process.env.GOOGLE_ID || 'id',
85     clientSecret: process.env.GOOGLE_SECRET || 'secret',
86     callbackURL: (process.env.DOMAIN || '') + '/auth/google/callback'
87   }
88 };
89
90 // Export the config object based on the NODE_ENV
91 // ==============================================
92 module.exports = _.merge(
93   all,
94   require('./' + process.env.NODE_ENV + '.js') || {});