-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (31 loc) · 1.09 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 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({//Middeleware
origin: [process.env.FRONTEND_URL,process.env.DASHBOARD_URL],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
}))
app.use(cookieParser());//To get Cookies
app.use(express.json());//To parse data into json format
app.use(express.urlencoded({extended: true}));
app.use(
fileUpload({
useTempFiles: true,
tempFileDir: "/tmp/",
}));
app.use("/api/v1/message",messageRouter)
app.use("/api/v1/user",userRouter)
app.use("/api/v1/appointment",appointmentRouter);
dbConnection();
app.use(errorMiddleware);
export default app;