This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
46 lines (42 loc) · 1.52 KB
/
init.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
'use strict';
var async = require('async'),
_ = require('lodash'),
logger = require('./lib/logger').Logger('init', 1);
/**
* Callback levels:
* - next: Top scope.
* - callback: Second scope.
* - cb: Third scope.
* ... After that, you're on your own.
*/
async.auto({
environment: require('./lib/environment'),
groups: require('./lib/groups').setupGroups,
database: require('./lib/database'),
certificate: require('./lib/certificate'),
httpd: require('./lib/httpd'),
middleware: require('./lib/middleware'),
models: require('./lib/models'),
routes: require('./lib/routes'),
integrity_routes: require('./lib/routes/integrity_routes'),
demographic_routes: require('./lib/routes/demographic_routes'),
medclass_routes: require('./lib/routes/medclass_routes'),
report_routes: require('./lib/routes/report_routes'),
metadata_routes: require('./lib/routes/metadata_routes'),
retro_routes : require('./lib/routes/retrospective_routes')
}, complete);
/**
* The final completion function. Throws any errors that arise, or listens.
* @param {Error} error Any errors passed to us via `next(err, null)`` from tasks.
* @param {Object} data The complete async data object.
*/
function complete(error, data) {
if (error) {
logger.error(error);
throw error;
}
// No errors
require('https').createServer(data.certificate, data.httpd).listen(process.env.PORT, function () {
logger.success('Server listening on port ' + process.env.PORT);
});
}