-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (28 loc) · 740 Bytes
/
index.js
File metadata and controls
32 lines (28 loc) · 740 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
const express = require("express");
const app = express();
const cors = require('cors')
const path = require("path");
const router = require("./src/routes");
const viewRouter = require("./frontend/src/routes");
const connectDB = require("./src/config/connect");
app.use(cors())
app.use(express.json());
app.use("/api", router);
app.set("view engine", "pug");
app.set("views", path.join(__dirname, "views"));
app.use(express.static("public"));
app.use(
express.static("views", {
extensions: ["html"],
})
);
app.use("/", viewRouter);
const bootstrap = async () => {
try {
await connectDB; // connect to Database
app.listen(4000);
} catch (error) {
console.log(error);
}
};
bootstrap();