-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (30 loc) · 974 Bytes
/
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
require("dotenv").config();
const express = require("express");
const path = require("path");
const app = express();
const { connectDB } = require("./server/services/database");
const bodyParser = require("body-parser");
const router = require("./router");
const session = require("express-session");
const port = process.env.port;
// Configure EJS as the view engine
app.set("view engine", "ejs");
// Specify the directory where your views (EJS templates) are located
app.set("views", path.join(__dirname, "client/views"));
app.use(express.static(path.join(__dirname, "client")));
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true,
})
);
connectDB().catch((err) => console.log(err));
app.use(bodyParser.urlencoded({ extended: true }));
// Other app configuration and routes
// ...
app.use(router);
// Start the Express server
app.listen(4000, () => {
console.log(`Server listening on port ${port}`);
});