-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (26 loc) · 869 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
const PORT = 9090;
const logger = require('./lib/logger');
logger.info(`Starting Blue Tie Inspection API Server on port ${PORT}...`);
const express = require("express");
const router = express.Router();
const app = express();
const {inputBodyBuffer} = require('./middlewares/bodyParser');
const {connectDatabase} = require('./lib/mongoDbClient');
logger.info('Connecting to MongoDB...');
connectDatabase('mongodb://localhost:27017', function() {
app.use(inputBodyBuffer);
router.use('/inspection', require('./controllers/inspection'));
app.use('/api', router);
app.listen(PORT, (e) => {
if(e){
logger.error('Error starting application', e)
process.exit();
}
else{
logger.info(`Application started on port: ${PORT}`);
}
})
}, function(e){
logger.error('Error in connecting to MongoDB', e);
process.exit()
});