From f0b96b80c8023513dd1e0c942ee4d079ab55db9f Mon Sep 17 00:00:00 2001 From: Leo K Date: Thu, 21 Oct 2021 22:58:09 +0200 Subject: [PATCH] chore: update router to 0.0.5 (#69) --- .github/workflows/ci.yml | 2 +- src/server/context.ts | 6 +++--- src/server/deps.ts | 2 +- src/server/types.ts | 6 ++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bbcf726..41a9d846 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: run: deno lint - name: Cache dependencies - run: deno cache --no-check src/*/deps.ts + run: deno cache --no-check src/cli/deps.ts src/runtime/deps.ts src/server/deps.ts - name: Run tests run: deno test -A --no-check diff --git a/src/server/context.ts b/src/server/context.ts index 3aeb6cb5..163a0005 100644 --- a/src/server/context.ts +++ b/src/server/context.ts @@ -187,12 +187,12 @@ export class ServerContext { (page.handler as Handler)({ req, match, - render: createRender(req, match.params), + render: createRender(req, match), }); } else { for (const [method, handler] of Object.entries(page.handler)) { routes[`${method}@${page.route}`] = (req, match) => - handler({ req, match, render: createRender(req, match.params) }); + handler({ req, match, render: createRender(req, match) }); } } } @@ -225,7 +225,7 @@ export class ServerContext { */ #bundleAssetRoute = (): router.MatchHandler => { return async (_req, match) => { - const path = `/${match.params.path}`; + const path = `/${match.path}`; const file = await this.#bundler.get(path); let res; if (file) { diff --git a/src/server/deps.ts b/src/server/deps.ts index f94110bc..fe5b8119 100644 --- a/src/server/deps.ts +++ b/src/server/deps.ts @@ -11,7 +11,7 @@ export { walk } from "https://deno.land/std@0.108.0/fs/walk.ts"; export { listenAndServe } from "https://deno.land/std@0.108.0/http/server.ts"; // -- router -- -export * as router from "https://crux.land/router@0.0.4"; +export * as router from "https://crux.land/router@0.0.5"; // -- media types -- export { lookup as mediaTypeLookup } from "https://deno.land/x/media_types@v2.10.2/mod.ts"; diff --git a/src/server/types.ts b/src/server/types.ts index e31db1ae..cde0b7d9 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -9,11 +9,9 @@ export interface PageModule { config?: PageConfig; } -export interface HandlerContext< - T extends Record = Record, -> { +export interface HandlerContext { req: Request; - match: router.MatchResult; + match: Record; render?: () => Promise; }