-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (33 loc) · 1.15 KB
/
index.js
File metadata and controls
38 lines (33 loc) · 1.15 KB
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
// This is index.js file of the backend. It is the entry point of the backend application. It is the first file that gets executed when the application starts.
// Required Libraries
const dotenv = require("dotenv");
dotenv.config();
const express = require("express");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const connectDB = require("./config/connectDB");
const userRoutes = require("./routes/userR");
const adminRoutes = require("./routes/adminR");
const cors = require("cors");
const path = require("path");
// Initialize express app
const app = express();
const port = 5013;
// Use the required libraries
app.use(cookieParser());
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "public")));
app.use(cors({ credentials: true, origin: "https://algo-vlab.kjsieit.com" }));
connectDB();
// Define the routes
app.get("/dbdb/yo", () => {
})
app.use("/y/user", userRoutes);
app.use("/y/admin", adminRoutes);
app.get("/", (req, res) => {
res.send("Hello User " + process.env.frontEndLink + " yoo");
})
// Start the server
app.listen(port, () => {
console.log(`Server running on port ${port}`);
})