-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cjs
36 lines (31 loc) · 1.01 KB
/
index.cjs
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
const express = require("express");
const session = require("express-session");
const favicon = require("serve-favicon");
const { resolve, join } = require("path");
const { inventoryRouter } = require("./routers/inventory.cjs");
const { dbClient } = require("./db/dbClient.cjs");
require("dotenv").config();
const app = express();
const PORT = 3000;
const faviconPath = join(__dirname, "public", "favicon.ico");
console.log(faviconPath);
app.use(favicon(faviconPath));
app.use(express.static(join(__dirname, "public")));
app.set("views", resolve(__dirname, "views"));
app.set("view engine", "ejs");
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.set("trust proxy", 1);
app.use(
session({
secret: process.env.SESSION_HASH,
resave: false,
saveUninitialized: true,
cookie: { secure: false },
})
);
app.get("/favicon.ico", (req, res) => res.status(204).end());
app.use("/", inventoryRouter);
app.listen(PORT, () => {
console.debug(`Listening at: http://localhost:${PORT}`);
});