diff --git a/src/endpoints/files/file_server.ts b/src/endpoints/files/file_server.ts new file mode 100644 index 0000000..9cf3b1a --- /dev/null +++ b/src/endpoints/files/file_server.ts @@ -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; \ No newline at end of file diff --git a/src/endpoints/files/vue.ts b/src/endpoints/files/vue.ts new file mode 100644 index 0000000..90748ac --- /dev/null +++ b/src/endpoints/files/vue.ts @@ -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; \ No newline at end of file