-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (28 loc) · 903 Bytes
/
index.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
import express from "express";
import dotenv from "dotenv";
import userRouter from "./router/staff.js";
import subAdminRouter from "./router/subAdmin.js";
import testRouter from "./router/testRouter.js";
import pcApiTest from "./router/pcApiTest.js";
import cors from "cors";
const app = express();
// const allowedOrigin = "http://localhost:5173/"; // Replace with your specific origin
const corsOptions = {
origin: true,
credentials: true,
optionsSuccessStatus: 200,
};
app.use(cors(corsOptions));
import bodyParser from "body-parser";
// import cors from "cors";
dotenv.config();
import "./db/mongDB.js";
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// app.use(cors());
app.use(userRouter);
app.use(subAdminRouter);
app.use(pcApiTest);
app.use(testRouter);
const PORT = process.env.PORT;
app.listen(PORT, console.log(`Serving at Port: ${PORT}`));