-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (26 loc) · 848 Bytes
/
app.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
'use strict';
// command line arguments
var optionDefs = [
{ name: 'app', alias: 'a', type: String, defaultOption: true, defaultValue: 'app' }
];
var clArgs = require('command-line-args');
var theArgs = clArgs(optionDefs);
var theApp = theArgs.app;
// setup the app
require('./config/common/mongoose');
var Archie = require('./config/common/archie.js'); // Archiejs setup
// Load the app's dependency tree
var deptree = require('./deptree');
var theAppTree = deptree[theApp];
if(!Array.isArray(theAppTree)) {
throw new Error(theApp + ' config does not export an ARRAY.')
}
// Setup the app
var tree = Archie.resolveConfig(theAppTree, process.cwd());
module.exports = Archie.createApp(tree, function(err, archie) {
if(err){
throw err;
}
require('./config/common/welcome');
})
.on('error', (err) => {throw err;});