-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
41 lines (31 loc) · 1.15 KB
/
index.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
import express, { NextFunction, Request, Response } from "express";
import authRouter from "./routes/auth.route";
import userRouter from "./routes/user.ruote"
import queryRouter from "./routes/query.route"
import hotelRouter from "./routes/hotel.route";
import propertyRouter from './routes/property.route'
import roomRouter from './routes/room.route';
import cors from "cors";
import morgan from "morgan";
import { AppError } from "./utils/appError";
import { errorHandler } from "./middlewares/error.middleware";
import { config } from "dotenv";
config();
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.use(morgan("dev"));
const PORT = process.env.PORT;
const DB = process.env.DATABASE_URL;
app.use("/api/v1/auth", authRouter);
app.use("/api/v1/user", userRouter);
app.use("/api/v1", queryRouter);
app.use("/api/v1",hotelRouter)
app.use("/api/v1",propertyRouter)
app.use("/api/v1",roomRouter)
app.all("*", (req: Request, _res: Response, next: NextFunction) => {
next(new AppError(`Can't find ${req.originalUrl} path on the server`, 404));
});
app.use(errorHandler);
export { app, PORT, DB };