1 import { setupDateFns } from "@utils/app";
2 import express from "express";
3 import path from "path";
4 import process from "process";
5 import CatchAllHandler from "./handlers/catch-all-handler";
6 import ManifestHandler from "./handlers/manifest-handler";
7 import RobotsHandler from "./handlers/robots-handler";
8 import ServiceWorkerHandler from "./handlers/service-worker-handler";
9 import ThemeHandler from "./handlers/theme-handler";
10 import ThemesListHandler from "./handlers/themes-list-handler";
11 import setDefaultCsp from "./middleware/set-default-csp";
13 const server = express();
15 const [hostname, port] = process.env["LEMMY_UI_HOST"]
16 ? process.env["LEMMY_UI_HOST"].split(":")
17 : ["0.0.0.0", "1234"];
19 server.use(express.json());
20 server.use(express.urlencoded({ extended: false }));
21 server.use("/static", express.static(path.resolve("./dist")));
23 if (!process.env["LEMMY_UI_DISABLE_CSP"] && !process.env["LEMMY_UI_DEBUG"]) {
24 server.use(setDefaultCsp);
27 server.get("/robots.txt", RobotsHandler);
28 server.get("/service-worker.js", ServiceWorkerHandler);
29 server.get("/manifest.webmanifest", ManifestHandler);
30 server.get("/css/themes/:name", ThemeHandler);
31 server.get("/css/themelist", ThemesListHandler);
32 server.get("/*", CatchAllHandler);
34 server.listen(Number(port), hostname, () => {
36 console.log(`http://${hostname}:${port}`);
39 process.on("SIGINT", () => {
40 console.info("Interrupted");