Add file servers for the overlays
This commit is contained in:
parent
57e4843976
commit
2ddb286efe
2 changed files with 42 additions and 0 deletions
28
src/endpoints/files/file_server.ts
Normal file
28
src/endpoints/files/file_server.ts
Normal 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;
|
||||
14
src/endpoints/files/vue.ts
Normal file
14
src/endpoints/files/vue.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { ServerRoute } from "@hapi/hapi";
|
||||
import { isDev } from "$/main";
|
||||
|
||||
const route: ServerRoute = {
|
||||
method: `GET`, path: `/vue.js`,
|
||||
options: {},
|
||||
handler(_, h) {
|
||||
if (isDev) {
|
||||
return h.redirect(`https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js`);
|
||||
}
|
||||
return h.redirect(`https://cdn.jsdelivr.net/npm/vue@2`);
|
||||
},
|
||||
};
|
||||
export default route;
|
||||
Loading…
Add table
Add a link
Reference in a new issue