-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (29 loc) · 829 Bytes
/
index.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 express = require("express");
const app = express();
const morgan = require("morgan");
const authRoutes = require("./routes/authRoutes");
const globalErrorHandler = require("./controller/errorcontroller");
console.log("HELLO");
// Development Logging
if (process.env.NODE_ENV == "development") {
app.use(morgan("dev"));
}
// Body parser reading data from the body to req.body
app.use(express.json({ limit: "10kb" })); // only kb data will be accepted
app.use(
express.urlencoded({
extended: true,
limit: "10kb",
})
);
app.use((req, res, next) => {
req.requestTime = new Date().toISOString();
// console.log(req.headers);
console.log(req.requestTime);
// console.log(req.cookies);
next();
});
// ROUTES
app.use("/api/v1/users", authRoutes);
app.use(globalErrorHandler);
module.exports = app;