-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (38 loc) · 1.21 KB
/
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
40
41
42
43
44
import express from "express";
import dotenv from "dotenv";
import DBConnect from "./DBModel/DBConnection.js"
import cors from "cors";
import bodyParser from "body-parser";
import expensesAPI from "./API/expenses/index.js"
import userAPI from "./API/user/index.js";
import organizationAPI from './API/organization/index.js';
import expenseFeildAPI from "./API/ExpenseField/index.js";
import requestAPI from "./API/Request/index.js";
import privateConfig from "./Config/routeConfig.js";
import passport from "passport";
import session from "express-session";
dotenv.config();
const app = express();
privateConfig(passport);
app.use(express.json());
const corsOptions = {
origin: "*",
credentials: true,
optionSuccessStatus: 200,
};
app.use(cors(corsOptions));
app.use(session({ secret: "newProject" }));
app.use(bodyParser.json());
app.use("/expenses", expensesAPI);
app.use("/user", userAPI);
app.use("/organization", organizationAPI);
app.use("/field", expenseFeildAPI)
app.use("/request", requestAPI)
app.listen(8000, () => {
DBConnect().then(() => {
console.log("server connected");
}).catch((error) => {
console.error(error);
})
console.log(`Server Started at ${8000}`)
})