1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | const express = require('express');
|
7 | const config = require('config');
|
8 |
|
9 | const init = require('./lib/init');
|
10 | const routes = require('./lib/routes');
|
11 |
|
12 | const application = express();
|
13 |
|
14 |
|
15 | const initApp = () => {
|
16 | return init(application).then(app => {
|
17 | return routes(app);
|
18 | }).catch(e => {
|
19 |
|
20 | console.log(e.stack);
|
21 | });
|
22 | };
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | if (!module.parent) {
|
28 | initApp().then(app => {
|
29 | app.listen(config.env.port, () => {
|
30 |
|
31 | console.log(`Server starting on ${config.env.url}`);
|
32 | });
|
33 | });
|
34 | }
|
35 |
|
36 | module.exports = initApp;
|