-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) · 752 Bytes
/
server.js
File metadata and controls
28 lines (22 loc) · 752 Bytes
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
require('dotenv').config();
const debug = require('debug')('app:server');
const winston = require('winston');
const { format } = require('winston');
const express = require('express');
const app = express();
require('./startup/logging')(winston);
require('./startup/routes')(app);
require('./startup/mongodb')();
require('./startup/config')();
require('./startup/validation')();
debug(`environment: ${app.get('env')}`);
//Logging only on development environment
if (app.get('env') === 'development') {
const morgan = require('morgan');
app.use(morgan('tiny'));
debug('morgan enabled');
} else {
require('./startup/prod')(app);
}
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => winston.info(`Listening on port ${PORT}...`));