celery/index.js
2024-07-28 06:37:14 -07:00

30 lines
756 B
JavaScript

require("dotenv").config();
const express = require("express");
const fs = require("fs");
const path = require("path");
const log = require("./log.js");
const stati = require("./static.js");
const app = express();
const dir = __dirname;
log.info("starting server");
require("express-ws")(app);
app.engine("html", require("mustache-express")());
app.set("views", path.join(dir, "assets"));
app.all("*", (req, res, next) => {
log.debug(`${req.method} request for ${req.url}, from ${req.headers["x-forwarded-for"]}`);
next();
});
for(let file of fs.readdirSync(dir + "/modules").sort()) {
require(dir + "/modules/" + file)(app, dir, log);
log.info(`loded module ${file}`);
}
app.get("*", stati.handle);
app.listen(3000, () => log.info("ready!"));