2015-06-14 23:04:49 +02:00
|
|
|
//configuration.js
|
2015-08-16 13:42:14 +02:00
|
|
|
/**
|
|
|
|
* Module for the return/creating of a settings file/object.
|
|
|
|
* @module configuration
|
2015-08-16 13:48:08 +02:00
|
|
|
* @author Bram van der Veen <96aa48@gmail.com>
|
2015-08-16 13:42:14 +02:00
|
|
|
*/
|
2015-08-16 01:37:27 +02:00
|
|
|
|
|
|
|
//Import first-party modules.
|
2015-06-14 23:04:49 +02:00
|
|
|
var fs = require('fs');
|
|
|
|
|
2015-08-16 01:37:27 +02:00
|
|
|
/**
|
2015-08-16 13:42:14 +02:00
|
|
|
* Function for the return/creating of a settings file/object.
|
2015-08-16 01:37:27 +02:00
|
|
|
* @return {Object} settings - Object of all the settings.
|
|
|
|
*/
|
2015-06-14 23:04:49 +02:00
|
|
|
module.exports = function () {
|
2015-06-16 15:26:12 +02:00
|
|
|
if (!fs.existsSync(__dirname + '/settings.json')) {
|
|
|
|
//Template for settings.json if not available.
|
|
|
|
var settings = {
|
|
|
|
'env' : 'dev',
|
2016-01-07 01:40:35 +01:00
|
|
|
'database' : 'localhost/roosterio',
|
2015-10-06 08:27:32 +02:00
|
|
|
"localDatabase" : true,
|
|
|
|
"webHost" : '0.0.0.0',
|
2015-08-15 21:07:22 +02:00
|
|
|
'webPort' : 1024,
|
2016-01-07 01:40:35 +01:00
|
|
|
'torHost' : 'localhost',
|
2015-08-15 21:07:22 +02:00
|
|
|
'torPort' : 9050,
|
|
|
|
'amountOfHours' : 7,
|
2015-08-31 08:32:21 +02:00
|
|
|
'encryptionKey': 'JMU6DAQpzt32hJ2WndJxFvk3WHWqFcscq9yMMYkr8kgTtsam',
|
2015-08-15 21:07:22 +02:00
|
|
|
'times' : [
|
2015-06-16 15:26:12 +02:00
|
|
|
'8:45 - 9:45',
|
|
|
|
'9:45 - 10:45',
|
|
|
|
'11:10 - 12:10',
|
|
|
|
'12:10 - 13:10',
|
|
|
|
'13:40 - 14:40',
|
|
|
|
'14:40 - 15:40',
|
|
|
|
'15:40 - 16:40'
|
|
|
|
],
|
2015-08-15 21:07:22 +02:00
|
|
|
'schoolID' : 934,
|
2015-07-22 15:50:05 +02:00
|
|
|
'linkbar' : {
|
2015-08-15 21:07:22 +02:00
|
|
|
'Roostersite': ['http://roosters5.gepro-osi.nl/roosters/rooster.php?school=INSERTYOURSCHOOLID', '#CCCC99'],
|
2015-07-21 17:01:45 +02:00
|
|
|
'Magister': ['http://INSERTYOURMAGISTER.magister.net', '#0C5489'],
|
2015-06-16 15:26:12 +02:00
|
|
|
'Mail': ['https://login.microsoftonline.com/', '#C41824']
|
2015-06-24 16:42:09 +02:00
|
|
|
},
|
2015-08-15 21:07:22 +02:00
|
|
|
'spiderTimeout' : 1000
|
2015-06-14 23:59:43 +02:00
|
|
|
}
|
2015-08-15 16:50:13 +02:00
|
|
|
//Write it to file as pretty printed JSON.
|
|
|
|
fs.writeFileSync(__dirname + '/settings.json', JSON.stringify(settings, null, 2));
|
2015-06-14 23:04:49 +02:00
|
|
|
|
2015-06-16 15:26:12 +02:00
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return JSON.parse(fs.readFileSync(__dirname + '/settings.json'));
|
|
|
|
}
|
2015-06-14 23:04:49 +02:00
|
|
|
}
|
|
|
|
|
2015-08-16 01:37:27 +02:00
|
|
|
//Testing command when passed a test argument in the commandline
|
2015-06-14 23:04:49 +02:00
|
|
|
if (process.argv[2] == 'test') {
|
2015-06-16 15:26:12 +02:00
|
|
|
console.log(module.exports());
|
2015-06-14 23:04:49 +02:00
|
|
|
}
|