-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (34 loc) · 1.18 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
const express = require("express");
const cookieParser = require("cookie-parser");
const app = express();
const database = require("./utils/database");
var cors = require("cors");
const port = process.env.PORT || 5000;
app.use(
cors({
origin: "*",
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
preflightContinue: false,
optionsSuccessStatus: 204,
})
);
app.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
const authRoutes = require("./routes/authRoutes");
app.use("/api/auth", authRoutes);
const userRoutes = require("./routes/userRoutes");
app.use("/api/user", userRoutes);
const probRoutes = require("./routes/problemRoutes");
app.use("/api/admin", probRoutes);
const submissionRoutes = require("./routes/submissionRoutes");
app.use("/api/submission", submissionRoutes);
const leaderboardRoutes = require("./routes/leaderboardRoutes");
app.use("/api/leaderboard", leaderboardRoutes);
database.on("error", console.error.bind(console, "connection error: "));
database.once("open", function () {
console.log("Database Connected successfully");
});
app.listen(port, function () {
console.log("App is running at port " + port);
});