-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (22 loc) · 827 Bytes
/
app.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
const express = require("express");
const app = express();
const morgan = require("morgan");
const tourRouter = require("./routers/tourRouter");
if (process.env.NODE_ENV === development) {
app.use(morgan("tiny"));
}
//if this middleware isnt used our response will throw undefined
app.use(express.json());
//serving static file to the server from a folder and not from a route,we use this middeleware
// app.use(express.static(`${__dirname}/dev_data`));
// app.use((req, res, next) => {
// console.log("hello from my middleware");
// next();
// });
app.use((req, res, next) => {
req.requestTime = new Date().toISOString();
//this is hw we can get access to the req headers in express, with bearer we posess the TOKEN
console.log(req.headers);
});
app.use("/api/v1/tours", tourRouter);
module.exports = app;