chore: update router to 0.0.5 (#69)
This commit is contained in:
@@ -33,7 +33,7 @@ jobs:
|
|||||||
run: deno lint
|
run: deno lint
|
||||||
|
|
||||||
- name: Cache dependencies
|
- 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
|
- name: Run tests
|
||||||
run: deno test -A --no-check
|
run: deno test -A --no-check
|
||||||
|
|||||||
@@ -187,12 +187,12 @@ export class ServerContext {
|
|||||||
(page.handler as Handler)({
|
(page.handler as Handler)({
|
||||||
req,
|
req,
|
||||||
match,
|
match,
|
||||||
render: createRender(req, match.params),
|
render: createRender(req, match),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for (const [method, handler] of Object.entries(page.handler)) {
|
for (const [method, handler] of Object.entries(page.handler)) {
|
||||||
routes[`${method}@${page.route}`] = (req, match) =>
|
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 => {
|
#bundleAssetRoute = (): router.MatchHandler => {
|
||||||
return async (_req, match) => {
|
return async (_req, match) => {
|
||||||
const path = `/${match.params.path}`;
|
const path = `/${match.path}`;
|
||||||
const file = await this.#bundler.get(path);
|
const file = await this.#bundler.get(path);
|
||||||
let res;
|
let res;
|
||||||
if (file) {
|
if (file) {
|
||||||
|
|||||||
+1
-1
@@ -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";
|
export { listenAndServe } from "https://deno.land/std@0.108.0/http/server.ts";
|
||||||
|
|
||||||
// -- router --
|
// -- 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 --
|
// -- media types --
|
||||||
export { lookup as mediaTypeLookup } from "https://deno.land/x/media_types@v2.10.2/mod.ts";
|
export { lookup as mediaTypeLookup } from "https://deno.land/x/media_types@v2.10.2/mod.ts";
|
||||||
|
|||||||
+2
-4
@@ -9,11 +9,9 @@ export interface PageModule {
|
|||||||
config?: PageConfig;
|
config?: PageConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HandlerContext<
|
export interface HandlerContext {
|
||||||
T extends Record<string, string> = Record<string, string>,
|
|
||||||
> {
|
|
||||||
req: Request;
|
req: Request;
|
||||||
match: router.MatchResult<T>;
|
match: Record<string, string>;
|
||||||
render?: () => Promise<Response>;
|
render?: () => Promise<Response>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user