This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
65 lines (50 loc) · 1.46 KB
/
Copy pathindex.js
File metadata and controls
65 lines (50 loc) · 1.46 KB
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
const _ = require('lodash');
const async = require('async');
const loadConfig = require('./lib/init/config');
const loadUtils = require('./lib/init/utils');
const preExpress = require('./lib/init/preExpress');
const postExpress = require('./lib/init/postExpress');
const startExpress = require('./lib/init/startExpress');
const loadMiddlewares = require('./lib/routes/middlewares');
const loadRoutes = require('./lib/routes/index');
const bootScripts = require('./lib/init/bootScripts');
// mongoose
const loadDb = require('./lib/db/index');
const getAppPath = require('./lib/private/utils/index').getAppPath;
const moduleRoot = getAppPath(module.parent ? module.parent.paths[0] : module.paths[0]);
// set globals
global.async = require('async');
global._ = require('lodash');
class Framework {
constructor() {
// default configuration
this.config = {
http: {
port: 6789,
public: 'public',
viewEngine: 'pug',
viewPath: 'views',
}
};
this.utils = {};
this.appPath = moduleRoot;
}
init(){
async.series([
loadConfig.bind(this),
loadUtils.bind(this),
loadDb.bind(this),
preExpress.bind(this),
loadMiddlewares.bind(this),
loadRoutes.bind(this),
postExpress.bind(this),
bootScripts.bind(this),
startExpress.bind(this),
], function (err) {
if (err){
console.error(err);
}
});
}
}
module.exports = global.Framework = new Framework();