0
0
Fork 0

Add file servers for the overlays

This commit is contained in:
Oliver-Akins 2023-02-19 20:42:06 -07:00
parent 57e4843976
commit 2ddb286efe
2 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import { ServerRoute } from "@hapi/hapi";
import { log } from "$/main";
import path from "path";
const route: ServerRoute = {
method: `GET`, path: `/{channel}/overlay/{theme}/{path*}`,
options: {
files: {
relativeTo: path.join(process.cwd(), `site`),
},
},
handler(request, h) {
// const theme = request.query.theme;
const path = request.params.path;
const theme = request.params.theme.replace(/\-/g, `/`);
let file: string;
if (path == null || path === `/`) {
file = `index.html`
} else {
file = path;
};
log.silly(`Attempting to load file ${file} from theme ${theme}`);
return h.file(`${theme}/${file}`);
},
};
export default route;