-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (23 loc) · 722 Bytes
/
app.js
File metadata and controls
32 lines (23 loc) · 722 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
const express = require('express');
const morgan = require('morgan');
const tourRouter = require('./routes/tourRoutes');
const userRouter = require('./routes/userRoutes');
const hotelRouter = require('./routes/hotelRoutes');
const app = express();
app.use(express.json());
if(process.env.NODE_ENV === 'development'){
app.use(morgan('dev'));
}
app.use(express.static(`${__dirname}/public`))
app.use((req,res, next) => {
console.log('Hello from the middleware');
next();
});
app.use((req,res,next) =>{
req.requestTime = new Date().toISOString();
next();
})
app.use('/api/v1/tours', tourRouter);
app.use('/api/v1/users', userRouter);
app.use('/api/v1/hotels', hotelRouter);
module.exports = app;