-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (23 loc) · 813 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
require('dotenv').config()
const express = require('express');
const http = require('http');
const bodyParser = require('body-parser');
const logger = require('winston');
const apiRoutes = require('./api/_index');
const errorMiddleware = require('./middleware/error');
logger.cli();
logger.level = 'debug';
const app = express();
const httpServer = http.createServer(app);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(errorMiddleware);
app.use('/api/v1', apiRoutes);
console.log('Starting server...');
global.__basepath = __dirname;
httpServer.listen(process.env.SERVER_PORT, () => {
let addr = httpServer.address();
let bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
logger.info('Listening on ' + bind);
});
module.exports = app;