f0bm/src/inc/routes/static.mjs
2021-12-24 11:15:30 +01:00

32 lines
632 B
JavaScript

import path from "path";
import { promises as fs } from "fs";
export default (router, tpl) => {
router.static({
dir: path.resolve() + "/public/b",
route: /^\/b\//
});
router.static({
dir: path.resolve() + "/public/s",
route: /^\/s\//
});
router.static({
dir: path.resolve() + "/public/t",
route: /^\/t\//
});
router.static({
dir: path.resolve() + "/public/ca",
route: /^\/ca\//
});
router.get(/^\/robots\.txt$/, async (req, res) => {
res.reply({
type: "text/plain",
body: await fs.readFile(path.resolve() + "/public/robots.txt", "utf-8")
});
});
};