-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (26 loc) · 777 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
30
31
32
import express from "express";
import dotenv from "dotenv";
import cors from "cors";
import { dbConnection } from "./database/dbConnection.js";
import { errorMiddleware } from "./error/error.js";
import reservationRouter from "./routes/reservation.js";
const port = process.env.PORT || 4000;
const app = express();
app.options('*', cors());
dotenv.config({ path: "./config/config.env" });
app.use(
cors({
origin: "https://brahmins.netlify.app",
methods: ["POST"],
credentials: true,
})
);
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
dbConnection();
app.use(errorMiddleware)
app.use("/api/reservation", reservationRouter);
app.listen(port, ()=>{
console.log(`SERVER HAS STARTED AT PORT ${port}`);
})
export default app;