-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
44 lines (38 loc) · 1.11 KB
/
app.ts
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
36
37
38
39
40
41
42
43
44
require("dotenv").config();
import express from "express";
import cors from "cors";
import cookieParser from "cookie-parser";
import { ErrorMiddleWare } from "./middleware/error";
import userRouter from "./routes/user.route";
import courseRouter from "./routes/course.route";
import orderRouter from "./routes/order.route";
import notificationRouter from "./routes/notification.route";
import analyticsRouter from "./routes/analytics.route";
import layoutRouter from "./routes/layout.route";
export const app = express();
app.use(express.json({ limit: "50mb" }));
app.use(cookieParser());
app.use(
cors({
origin: process.env.ORIGIN,
})
);
//
app.use("/api/v1", userRouter);
app.use("/api/v1", courseRouter);
app.use("/api/v1", orderRouter);
app.use("/api/v1", notificationRouter);
app.use("/api/v1", analyticsRouter);
app.use("/api/v1", layoutRouter);
app.get("/test", (req, res) => {
res.status(200).json({
success: true,
message: "XDD",
});
});
app.all("*", (req, res, next) => {
const err = new Error(`route ${req.originalUrl} not found`);
res.status(404);
next(err);
});
app.use(ErrorMiddleWare);