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
|
const express = require("express");
const rateLimit = require("express-rate-limit");
const path = require("node:path");
const geddit = require("./geddit.js");
const cookieParser = require("cookie-parser");
const app = express();
const hasher = new Bun.CryptoHasher("sha256", "secret-key");
const JWT_KEY = hasher.update(Math.random().toString()).digest("hex");
module.exports = { JWT_KEY };
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");
const routes = require("./routes/index");
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "public")));
app.use(express.static(path.join(__dirname, "assets")));
app.use(cookieParser());
app.use(
rateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
message: "Too many requests from this IP, please try again later.",
standardHeaders: true,
legacyHeaders: false,
}),
);
app.use("/", routes);
const port = process.env.LURKER_PORT;
const server = app.listen(port ? port : 3000, () => {
console.log(`started on ${server.address().port}`);
});
|