forked from punchcard-cms/punchcard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (30 loc) · 843 Bytes
/
index.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
'use strict';
/**
* @fileoverview Punchcard CMS Init
*/
const express = require('express');
const config = require('config');
const init = require('./lib/init');
const routes = require('./lib/routes');
const application = express();
// Initialize the Database
const initApp = () => {
return init(application).then(app => {
return routes(app);
}).catch(e => {
// Mean to console.log out, so disabling
console.log(e.stack); // eslint-disable-line no-console
});
};
/*
@description run the server if and only if this file is being run directly
*/
if (!module.parent) {
initApp().then(app => {
app.listen(config.env.port, () => {
// Mean to console.log out, so disabling
console.log(`Server starting on ${config.env.url}`); // eslint-disable-line no-console
});
});
}
module.exports = initApp;