From 832f48f29098cc6f840ade90db3b94efa67c6833 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 7 Sep 2022 10:20:44 +0200 Subject: about to refactor --- source/server/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source/server/index.ts') diff --git a/source/server/index.ts b/source/server/index.ts index f77d8a5..de2ba4e 100644 --- a/source/server/index.ts +++ b/source/server/index.ts @@ -5,6 +5,7 @@ import { bundle } from "https://deno.land/x/emit@0.1.1/mod.ts"; const app = new Application() const root = new Router() + root.get("/", async c => { await c.send({ path: "index.html", root: `${Deno.cwd()}/public` }) }) root.get("/room/:id", async c => { await c.send({ path: "index.html", root: `${Deno.cwd()}/public` }) }) @@ -26,17 +27,17 @@ function respondWithType(mimeType: string, f: () => string): (c: RouterContext bundle_code)) +root.use(api.routes()) + function mountFilesystem(r: Router, route: string, path: string) { r.get(route + "/(.*)", async (context) => { - await send(context, context.request.url.pathname, { root: Deno.cwd() + path }); + console.log(context.request.url.pathname.substring(route.length)); + await send(context, context.request.url.pathname.substring(route.length), { root: Deno.cwd() + path }); }) - } -mountFilesystem(root, "/style", "/public") -mountFilesystem(root, "/rnnoise", "/public") - -root.use(api.routes()) +mountFilesystem(root, "/_style", "/public/style") +mountFilesystem(root, "/_rnnoise", "/public/rnnoise") app.use(root.routes()) app.use(root.allowedMethods()) -- cgit v1.2.3-70-g09d2