forked from SnTC-IITMandi/TedX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (23 loc) · 736 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
const path = require("path");
const morgan = require("morgan");
const AppError = require("./utils/appError");
const globalErrorHandler = require("./controllers/errorController");
const speakerRouter = require("./routes/speakerRoutes");
const express = require("express");
const app = express();
// Development logging
if (process.env.NODE_ENV === "development") {
app.use(morgan("dev"));
}
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Serving static files
app.use(express.static(`${__dirname}/public`));
// Test middleware
app.use((req, res, next) => {
req.requestTime = new Date().toISOString();
next();
});
// ROUTES
app.use("/api/v1/speakers", speakerRouter);
module.exports = app;