-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (26 loc) · 816 Bytes
/
server.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
/**
* Project Beautyland API
* @author Roy Lu(royxnatw)
*/
const express = require('express');
const bodyParser = require('body-parser');
const log = require('services/log-service').init('accessLog');
async function createServer(port) {
try {
log.info('App started.');
const app = express();
app.use(express.static(__dirname + '/public'));
// Setup CORS middleware
const cors = require('cors');
app.use(cors());
app.use(bodyParser.json());
app.use(require('./controllers/routers'));
log.info('createServer() init finished.');
return app.listen(port = 3004, function() {
log.info(`Beautyland-API is listening on ${port}`);
});
} catch(ex) {
log.error({args: arguments, ex: ex.stack}, 'Error in index.init()');
}
}
module.exports = createServer;