2023-02-23 21:58:23 +01:00
|
|
|
const express = require("express");
|
2023-02-23 19:48:08 +01:00
|
|
|
const app = express();
|
|
|
|
|
2023-02-23 21:58:23 +01:00
|
|
|
const { join } = require("path");
|
2023-02-23 19:48:08 +01:00
|
|
|
|
2023-02-23 21:58:23 +01:00
|
|
|
const compression = require("compression");
|
|
|
|
const expressEJSLayouts = require("express-ejs-layouts");
|
2023-02-23 19:48:08 +01:00
|
|
|
|
|
|
|
app.disable('x-powered-by');
|
|
|
|
|
|
|
|
app.use(compression());
|
|
|
|
app.use(express.static(join(__dirname, "public")));
|
|
|
|
|
|
|
|
app.set("view engine", "ejs");
|
|
|
|
app.set("views", join(__dirname, "views"));
|
|
|
|
|
|
|
|
app.set("layout extractScripts", true);
|
|
|
|
app.set("layout extractStyles", true);
|
|
|
|
app.use(expressEJSLayouts);
|
|
|
|
|
|
|
|
app.use((req, res, next) => {
|
|
|
|
// Security Headers - Refer to MDN and helmetjs docs
|
2023-02-24 01:13:01 +01:00
|
|
|
res.set("Content-Security-Policy", `default-src 'self'; img-src 'self'; media-src 'self'; script-src 'unsafe-inline' 'self' https://cdn.jsdelivr.net https://code.jquery.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; font-src 'self' data:; object-src 'none'; child-src 'none'; frame-ancestors 'none'; frame-src 'none'; upgrade-insecure-requests`);
|
2023-02-23 19:48:08 +01:00
|
|
|
res.set("Strict-Transport-Security", "max-age=15552000; includeSubDomains");
|
|
|
|
res.set("X-Content-Type-Options", "nosniff");
|
|
|
|
res.set("X-Frame-Options", "DENY");
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get("/", (req, res) => {
|
|
|
|
res.render("home");
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get("/rices", (req, res) => {
|
|
|
|
res.render("rices");
|
|
|
|
});
|
|
|
|
|
2023-02-25 20:16:40 +01:00
|
|
|
app.get("/discord", (req, res) => {
|
|
|
|
res.status(200).send("<head><title>redirecting...</title><body><script>window.location.href='https://discord.gg/hQ9XvMUjjr';</script></body>");
|
|
|
|
});
|
|
|
|
|
2023-02-23 19:48:08 +01:00
|
|
|
app.use((_, res) => {
|
|
|
|
res.status(404).render("404");
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(process.env.PORT || 4000, () => {
|
|
|
|
console.log("Listening to PORT: 4000");
|
|
|
|
});
|