From 803687b2192c5026bbb2221e1d9c1d371694530a Mon Sep 17 00:00:00 2001 From: xion Date: Wed, 19 Feb 2025 07:03:09 +0800 Subject: [PATCH] style --- src/route.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/route.ts b/src/route.ts index c3abb73..4fcc3a5 100644 --- a/src/route.ts +++ b/src/route.ts @@ -63,6 +63,9 @@ export type RouteOpts = { isVerify?: boolean; verify?: (ctx?: RouteContext, dev?: boolean) => boolean; verifyKey?: (key: string, ctx?: RouteContext, dev?: boolean) => boolean; + /** + * $#$ will be used to split path and key + */ idUsePath?: boolean; isDebug?: boolean; }; @@ -282,8 +285,8 @@ export class QueryRouter { * remove route by path and key * @param route */ - remove(route: Route | { path: string; key: string }) { - this.routes = this.routes.filter((r) => r.path === route.path && r.key === route.key); + remove(route: Route | { path: string; key?: string }) { + this.routes = this.routes.filter((r) => r.path === route.path && r.key == route.key); } /** * remove route by id @@ -548,6 +551,9 @@ export class QueryRouter { throw(...args: any[]) { throw new CustomError(...args); } + hasRoute(path: string, key?: string) { + return this.routes.find((r) => r.path === path && r.key === key); + } } type QueryRouterServerOpts = {