-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathconfig.js
executable file
·120 lines (95 loc) · 3.73 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
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
/**
* Module Dependencies
*/
var pkg = require('./package.json');
var dotenv = require('dotenv'); // https://www.npmjs.com/package/dotenv
var path = require('path');
// *For Development Purposes*
// Read in environment vars from .env file
dotenv.load();
/**
* Configuration File
*
* Why like this?
*
* - All environmental variables documented in one place
* - If I use "." notation it's easy to cut/paste into code
* - Unlike JSON, javascript allows comments (which I like)
* - Reading package.json here centralizes all config info
*
*/
var config = {};
// From package.json
config.name = pkg.name;
config.version = pkg.version;
config.description = pkg.description;
config.company = pkg.company;
config.author = pkg.author;
config.keywords = pkg.keywords;
config.environment = process.env.NODE_ENV || 'development';
config.port = process.env.PORT || 3000;
config.root = process.env.ROOT_URL || ('http://localhost:' + config.port);
config.logging = false;
config.rateLimit = 1000;
config.gpg = {};
config.gpg.home = process.env.GNUPGHOME || (path.join(__dirname, 'gnupg'));
config.repositories = {};
config.repositories.root = process.env.GIT_REPOSITORIES_ROOT || (path.join(__dirname, 'repositories'));
/**
* Database Configuration
*/
config.mongodb = {};
config.mongodb.url = process.env.XIMERA_MONGO_URL || '127.0.0.1';
config.mongodb.database = process.env.XIMERA_MONGO_DATABASE || 'ximera';
/**
* Session Configuration
*/
var hour = 3600000;
var day = (hour * 24);
var week = (day * 7);
// Session
config.session = {};
config.session.secret = process.env.XIMERA_COOKIE_SECRET || 'my big secret';
config.session.name = 'sid'; // Generic - don't leak information
config.session.proxy = false; // Trust the reverse proxy for HTTPS/SSL
config.session.resave = false; // Forces session to be saved even when unmodified
config.session.saveUninitialized = false; // forces a session that is "uninitialized" to be saved to the store
config.session.cookie = {};
config.session.cookie.httpOnly = true; // Reduce XSS attack vector
config.session.cookie.secure = false; // Cookies via HTTPS/SSL
config.session.cookie.maxAge = process.env.SESSION_MAX_AGE || week;
/**
* Mailing Configuration
*/
config.smtp = {};
config.smtp.name = process.env.SMTP_FROM_NAME || 'Ximera Team';
config.smtp.address = process.env.SMTP_FROM_ADDRESS || '[email protected]';
/**
* Authorization Configuration
*/
config.localAuth = false;
if (config.environment == 'development') {
config.localAuth = true;
}
// Github
config.githubAuth = true;
config.github = {};
config.github.clientID = process.env.GITHUB_CLIENT_ID || 'Your Key';
config.github.clientSecret = process.env.GITHUB_CLIENT_SECRET || 'Your Secret';
// Twitter
config.twitterAuth = true;
config.twitter = {};
config.twitter.consumerKey = process.env.TWITTER_CONSUMER_KEY || 'Your Key';
config.twitter.consumerSecret = process.env.TWITTER_CONSUMER_SECRET || 'Your Secret';
// Google
config.googleAuth = true;
config.google = {};
config.google.clientID = process.env.GOOGLE_CLIENT_ID || 'Your Key';
config.google.clientSecret = process.env.GOOGLE_CLIENT_SECRET || 'Your Secret';
// LTI
config.ltiAuth = true;
config.lti = {};
config.lti.key = process.env.LTI_KEY || 'Your Key';
config.lti.secret = process.env.LTI_SECRET || 'Your Secret';
module.exports = config;