-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (31 loc) · 1.23 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
import express, { urlencoded } from "express";
import {config} from "dotenv";
import cors from "cors";
import cookieParser from "cookie-parser";
import fileUpload from "express-fileupload";
import { dbConnection } from "./database/dbConnection.js";
import messageRouter from "./router/messageRouter.js";
import { errorMiddleware } from "./middlewares/errorMiddleware.js";
import userRouter from "./router/userRouter.js";
import appointmentRouter from "./router/appointmentRouter.js";
const app = express();
config({path: "./config/config.env"})
app.use(cors({
origin: [process.env.FRONTEND_URL, process.env.DASHBOARD_URL],
methods:["GET", "PUT", "POST", "DELETE"],
credentials: true,
}));
app.use(cookieParser());
app.use(express.json()); //parse krega data ko json mei
app.use(urlencoded({extended:true}));
app.use(express.urlencoded({ extended: true })); // br point ho sakta hai ,error remove krne ke liye lgaya tha
app.use(fileUpload({
useTempFiles:true,
tempFileDir: "/temp/",
}));
app.use("/api/v1/message", messageRouter);
app.use("/api/v1/user", userRouter);
app.use("/api/v1/appointment", appointmentRouter);
dbConnection();
app.use(errorMiddleware); //this error middleware should always be kept in last
export default app;