-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
36 lines (26 loc) · 866 Bytes
/
main.js
File metadata and controls
36 lines (26 loc) · 866 Bytes
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
// Description: This is the main file of the project
// Get the environment variables
require("dotenv").config();
// Connect to the database
require("./src/config/db.config");
// Import the express module
const express = require("express");
const cors = require("cors");
const app = express();
app.use(express.urlencoded({ extended: true }));
// Make the app use the json parser
app.use(express.json());
app.use(cors({ origin: true, credentials: true }));
// Import the routes
const authRoute = require("./src/routes/auth");
const usersRoute = require("./src/routes/users");
// Route middlewares
app.use("/auth", authRoute);
app.use("/users", usersRoute);
app.get("/", (req, res) => {
res.send("WebPods API is running");
});
// Start the server
app.listen(process.env.PORT, () => {
console.log(`Server is running on PORT ${process.env.PORT}`);
});