-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (25 loc) · 739 Bytes
/
index.js
File metadata and controls
35 lines (25 loc) · 739 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
29
30
31
32
33
34
35
require('dotenv').config();
const express = require('express');
const logger = require('morgan');
const bodyParser = require('body-parser');
const app = express();
const router = express.Router();
const environment = process.env.NODE_ENV;
const stage = require('./config')[environment];
const routes = require('./routes/index.js');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
if (environment !== 'production') {
app.use(logger('dev'));
}
app.use('/api/v1', routes(router));
// app.use('/api/v1', (req, res, next) => {
// res.send('Hello');
// next();
// });
app.listen(`${stage.port}`, () => {
console.log(`Server now listening at localhost:${stage.port}`);
});
module.exports = app;