Built motion from commit cad11dd.|0.0.45
[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   // Root path of server
18   root: path.normalize(__dirname + '/../../..'),
19
20   // Root path of moh
21   moh: path.normalize(__dirname + '/../../..' + '/server/files/moh'),
22
23   // Root path of saved reports
24   reports: path.normalize(__dirname + '/../../..' + '/server/files/reports/'),
25
26   // Root path of fonts
27   fonts: path.normalize(__dirname + '/../../..' + '/server/utils/fonts/'),
28
29   // Root path of original sounds
30   originalSounds: path.normalize(__dirname + '/../../..' + '/server/files/sounds/original'),
31
32   // Root path of converted sounds
33   convertedSounds: path.normalize(__dirname + '/../../..' + '/server/files/sounds/converted'),
34
35   // Server port
36   port: process.env.PORT || 9000,
37
38   // Server ip
39   ip: process.env.IP || 'localhost',
40
41   // Should we populate the DB with sample data?
42   seedDB: false,
43
44   // Secret for session, you will want to change this and make it an environment variable
45   session: {
46     name: 'xcally-motion',
47     secret: 'xcally-motion-session-secret',
48     cookie: {
49       path: '/',
50       httpOnly: true,
51       // If secure is set to true then it will cause the cookie to be set
52       // only when SSL-enabled (HTTPS) is used, and otherwise it won't
53       // set a cookie. 'true' is recommended yet it requires the above
54       // mentioned pre-requisite.
55       secure: false,
56       // Only set the maxAge to null if the cookie shouldn't be expired
57       // at all. The cookie will expunge when the browser is closed.
58       maxAge: null
59     }
60   },
61
62   // List of user roles
63   userRoles: ['guest', 'user', 'admin'],
64
65   facebook: {
66     clientID: process.env.FACEBOOK_ID || 'id',
67     clientSecret: process.env.FACEBOOK_SECRET || 'secret',
68     callbackURL: (process.env.DOMAIN || '') + '/auth/facebook/callback'
69   },
70
71   twitter: {
72     clientID: process.env.TWITTER_ID || 'id',
73     clientSecret: process.env.TWITTER_SECRET || 'secret',
74     callbackURL: (process.env.DOMAIN || '') + '/auth/twitter/callback'
75   },
76
77   google: {
78     clientID: process.env.GOOGLE_ID || 'id',
79     clientSecret: process.env.GOOGLE_SECRET || 'secret',
80     callbackURL: (process.env.DOMAIN || '') + '/auth/google/callback'
81   }
82 };
83
84 // Export the config object based on the NODE_ENV
85 // ==============================================
86 module.exports = _.merge(
87   all,
88   require('./' + process.env.NODE_ENV + '.js') || {});