@devbro/neko-router 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Router.js +0 -1
- package/dist/Router.js.map +1 -1
- package/dist/Router.mjs +0 -1
- package/dist/Router.mjs.map +1 -1
- package/package.json +1 -1
package/dist/Router.js
CHANGED
|
@@ -107,7 +107,6 @@ class Router {
|
|
|
107
107
|
if (!match) {
|
|
108
108
|
return void 0;
|
|
109
109
|
}
|
|
110
|
-
request.query = Object.fromEntries(match.url.searchParams.entries());
|
|
111
110
|
request.params = match.params;
|
|
112
111
|
return new import_CompiledRoute.CompiledRoute(route, request, response, this.middlewares);
|
|
113
112
|
}
|
package/dist/Router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Router.ts"],"sourcesContent":["import { CompiledRoute } from './CompiledRoute';\nimport { BaseController } from './Controller';\nimport { Middleware } from './Middleware';\nimport { MiddlewareFactory } from './MiddlewareFactory';\nimport { Route } from './Route';\nimport { HandlerType, HttpMethod, MiddlewareProvider } from './types';\nimport { LexerToken, Request, Response } from './types';\nimport path from 'path';\n\nexport class Router {\n private middlewares: MiddlewareProvider[] = [];\n routes: Route[] = [];\n addRoute(methods: HttpMethod[], path: string, handler: HandlerType) {\n const route: Route = new Route(methods, path, handler);\n this.routes.push(route);\n return route;\n }\n\n getMiddlewares() {\n return [...this.middlewares];\n }\n\n addController(controller: typeof BaseController) {\n const basePath = controller.basePath || '';\n for (const route of controller.routes) {\n const urlPath = path.join(basePath, route.path);\n this.addRoute(route.methods, urlPath, async (req: Request, res: Response) => {\n const controllerInstance = controller.getInstance();\n // @ts-ignore\n return await controllerInstance[route.handler]();\n }).addMiddleware([...controller.baseMiddlewares, ...route.middlewares]);\n }\n }\n\n addGlobalMiddleware(middlewares: MiddlewareProvider | MiddlewareProvider[]) {\n this.middlewares = this.middlewares.concat(middlewares);\n }\n\n resolve(request: Request): Route | undefined {\n for (const route of this.routes) {\n if (route.test(request)) {\n return route;\n }\n }\n return undefined;\n }\n\n resolveMultiple(request: Request): Route[] {\n const rc: Route[] = [];\n const url = new URL(request.url || '/', 'http://localhost');\n for (const route of this.routes) {\n if (route.testPath(url.pathname)) {\n rc.push(route);\n }\n }\n return rc;\n }\n\n getCompiledRoute(request: Request, response: Response) {\n const route = this.resolve(request);\n if (!route) {\n return undefined;\n }\n const match = route.match(request);\n if (!match) {\n return undefined;\n }\n\n request.
|
|
1
|
+
{"version":3,"sources":["../src/Router.ts"],"sourcesContent":["import { CompiledRoute } from './CompiledRoute';\nimport { BaseController } from './Controller';\nimport { Middleware } from './Middleware';\nimport { MiddlewareFactory } from './MiddlewareFactory';\nimport { Route } from './Route';\nimport { HandlerType, HttpMethod, MiddlewareProvider } from './types';\nimport { LexerToken, Request, Response } from './types';\nimport path from 'path';\n\nexport class Router {\n private middlewares: MiddlewareProvider[] = [];\n routes: Route[] = [];\n addRoute(methods: HttpMethod[], path: string, handler: HandlerType) {\n const route: Route = new Route(methods, path, handler);\n this.routes.push(route);\n return route;\n }\n\n getMiddlewares() {\n return [...this.middlewares];\n }\n\n addController(controller: typeof BaseController) {\n const basePath = controller.basePath || '';\n for (const route of controller.routes) {\n const urlPath = path.join(basePath, route.path);\n this.addRoute(route.methods, urlPath, async (req: Request, res: Response) => {\n const controllerInstance = controller.getInstance();\n // @ts-ignore\n return await controllerInstance[route.handler]();\n }).addMiddleware([...controller.baseMiddlewares, ...route.middlewares]);\n }\n }\n\n addGlobalMiddleware(middlewares: MiddlewareProvider | MiddlewareProvider[]) {\n this.middlewares = this.middlewares.concat(middlewares);\n }\n\n resolve(request: Request): Route | undefined {\n for (const route of this.routes) {\n if (route.test(request)) {\n return route;\n }\n }\n return undefined;\n }\n\n resolveMultiple(request: Request): Route[] {\n const rc: Route[] = [];\n const url = new URL(request.url || '/', 'http://localhost');\n for (const route of this.routes) {\n if (route.testPath(url.pathname)) {\n rc.push(route);\n }\n }\n return rc;\n }\n\n getCompiledRoute(request: Request, response: Response) {\n const route = this.resolve(request);\n if (!route) {\n return undefined;\n }\n const match = route.match(request);\n if (!match) {\n return undefined;\n }\n\n request.params = match.params;\n return new CompiledRoute(route, request, response, this.middlewares);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA8B;AAI9B,mBAAsB;AAGtB,kBAAiB;AAEV,MAAM,OAAO;AAAA,EAAb;AACL,SAAQ,cAAoC,CAAC;AAC7C,kBAAkB,CAAC;AAAA;AAAA,EACnB,SAAS,SAAuBA,OAAc,SAAsB;AAClE,UAAM,QAAe,IAAI,mBAAM,SAASA,OAAM,OAAO;AACrD,SAAK,OAAO,KAAK,KAAK;AACtB,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB;AACf,WAAO,CAAC,GAAG,KAAK,WAAW;AAAA,EAC7B;AAAA,EAEA,cAAc,YAAmC;AAC/C,UAAM,WAAW,WAAW,YAAY;AACxC,eAAW,SAAS,WAAW,QAAQ;AACrC,YAAM,UAAU,YAAAA,QAAK,KAAK,UAAU,MAAM,IAAI;AAC9C,WAAK,SAAS,MAAM,SAAS,SAAS,CAAO,KAAc,QAAkB;AAC3E,cAAM,qBAAqB,WAAW,YAAY;AAElD,eAAO,MAAM,mBAAmB,MAAM,OAAO,EAAE;AAAA,MACjD,EAAC,EAAE,cAAc,CAAC,GAAG,WAAW,iBAAiB,GAAG,MAAM,WAAW,CAAC;AAAA,IACxE;AAAA,EACF;AAAA,EAEA,oBAAoB,aAAwD;AAC1E,SAAK,cAAc,KAAK,YAAY,OAAO,WAAW;AAAA,EACxD;AAAA,EAEA,QAAQ,SAAqC;AAC3C,eAAW,SAAS,KAAK,QAAQ;AAC/B,UAAI,MAAM,KAAK,OAAO,GAAG;AACvB,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,gBAAgB,SAA2B;AACzC,UAAM,KAAc,CAAC;AACrB,UAAM,MAAM,IAAI,IAAI,QAAQ,OAAO,KAAK,kBAAkB;AAC1D,eAAW,SAAS,KAAK,QAAQ;AAC/B,UAAI,MAAM,SAAS,IAAI,QAAQ,GAAG;AAChC,WAAG,KAAK,KAAK;AAAA,MACf;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB,SAAkB,UAAoB;AACrD,UAAM,QAAQ,KAAK,QAAQ,OAAO;AAClC,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AACA,UAAM,QAAQ,MAAM,MAAM,OAAO;AACjC,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AAEA,YAAQ,SAAS,MAAM;AACvB,WAAO,IAAI,mCAAc,OAAO,SAAS,UAAU,KAAK,WAAW;AAAA,EACrE;AACF;","names":["path"]}
|
package/dist/Router.mjs
CHANGED
package/dist/Router.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Router.ts"],"sourcesContent":["import { CompiledRoute } from './CompiledRoute';\nimport { BaseController } from './Controller';\nimport { Middleware } from './Middleware';\nimport { MiddlewareFactory } from './MiddlewareFactory';\nimport { Route } from './Route';\nimport { HandlerType, HttpMethod, MiddlewareProvider } from './types';\nimport { LexerToken, Request, Response } from './types';\nimport path from 'path';\n\nexport class Router {\n private middlewares: MiddlewareProvider[] = [];\n routes: Route[] = [];\n addRoute(methods: HttpMethod[], path: string, handler: HandlerType) {\n const route: Route = new Route(methods, path, handler);\n this.routes.push(route);\n return route;\n }\n\n getMiddlewares() {\n return [...this.middlewares];\n }\n\n addController(controller: typeof BaseController) {\n const basePath = controller.basePath || '';\n for (const route of controller.routes) {\n const urlPath = path.join(basePath, route.path);\n this.addRoute(route.methods, urlPath, async (req: Request, res: Response) => {\n const controllerInstance = controller.getInstance();\n // @ts-ignore\n return await controllerInstance[route.handler]();\n }).addMiddleware([...controller.baseMiddlewares, ...route.middlewares]);\n }\n }\n\n addGlobalMiddleware(middlewares: MiddlewareProvider | MiddlewareProvider[]) {\n this.middlewares = this.middlewares.concat(middlewares);\n }\n\n resolve(request: Request): Route | undefined {\n for (const route of this.routes) {\n if (route.test(request)) {\n return route;\n }\n }\n return undefined;\n }\n\n resolveMultiple(request: Request): Route[] {\n const rc: Route[] = [];\n const url = new URL(request.url || '/', 'http://localhost');\n for (const route of this.routes) {\n if (route.testPath(url.pathname)) {\n rc.push(route);\n }\n }\n return rc;\n }\n\n getCompiledRoute(request: Request, response: Response) {\n const route = this.resolve(request);\n if (!route) {\n return undefined;\n }\n const match = route.match(request);\n if (!match) {\n return undefined;\n }\n\n request.
|
|
1
|
+
{"version":3,"sources":["../src/Router.ts"],"sourcesContent":["import { CompiledRoute } from './CompiledRoute';\nimport { BaseController } from './Controller';\nimport { Middleware } from './Middleware';\nimport { MiddlewareFactory } from './MiddlewareFactory';\nimport { Route } from './Route';\nimport { HandlerType, HttpMethod, MiddlewareProvider } from './types';\nimport { LexerToken, Request, Response } from './types';\nimport path from 'path';\n\nexport class Router {\n private middlewares: MiddlewareProvider[] = [];\n routes: Route[] = [];\n addRoute(methods: HttpMethod[], path: string, handler: HandlerType) {\n const route: Route = new Route(methods, path, handler);\n this.routes.push(route);\n return route;\n }\n\n getMiddlewares() {\n return [...this.middlewares];\n }\n\n addController(controller: typeof BaseController) {\n const basePath = controller.basePath || '';\n for (const route of controller.routes) {\n const urlPath = path.join(basePath, route.path);\n this.addRoute(route.methods, urlPath, async (req: Request, res: Response) => {\n const controllerInstance = controller.getInstance();\n // @ts-ignore\n return await controllerInstance[route.handler]();\n }).addMiddleware([...controller.baseMiddlewares, ...route.middlewares]);\n }\n }\n\n addGlobalMiddleware(middlewares: MiddlewareProvider | MiddlewareProvider[]) {\n this.middlewares = this.middlewares.concat(middlewares);\n }\n\n resolve(request: Request): Route | undefined {\n for (const route of this.routes) {\n if (route.test(request)) {\n return route;\n }\n }\n return undefined;\n }\n\n resolveMultiple(request: Request): Route[] {\n const rc: Route[] = [];\n const url = new URL(request.url || '/', 'http://localhost');\n for (const route of this.routes) {\n if (route.testPath(url.pathname)) {\n rc.push(route);\n }\n }\n return rc;\n }\n\n getCompiledRoute(request: Request, response: Response) {\n const route = this.resolve(request);\n if (!route) {\n return undefined;\n }\n const match = route.match(request);\n if (!match) {\n return undefined;\n }\n\n request.params = match.params;\n return new CompiledRoute(route, request, response, this.middlewares);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAI9B,SAAS,aAAa;AAGtB,OAAO,UAAU;AAEV,MAAM,OAAO;AAAA,EAAb;AACL,SAAQ,cAAoC,CAAC;AAC7C,kBAAkB,CAAC;AAAA;AAAA,EACnB,SAAS,SAAuBA,OAAc,SAAsB;AAClE,UAAM,QAAe,IAAI,MAAM,SAASA,OAAM,OAAO;AACrD,SAAK,OAAO,KAAK,KAAK;AACtB,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB;AACf,WAAO,CAAC,GAAG,KAAK,WAAW;AAAA,EAC7B;AAAA,EAEA,cAAc,YAAmC;AAC/C,UAAM,WAAW,WAAW,YAAY;AACxC,eAAW,SAAS,WAAW,QAAQ;AACrC,YAAM,UAAU,KAAK,KAAK,UAAU,MAAM,IAAI;AAC9C,WAAK,SAAS,MAAM,SAAS,SAAS,CAAO,KAAc,QAAkB;AAC3E,cAAM,qBAAqB,WAAW,YAAY;AAElD,eAAO,MAAM,mBAAmB,MAAM,OAAO,EAAE;AAAA,MACjD,EAAC,EAAE,cAAc,CAAC,GAAG,WAAW,iBAAiB,GAAG,MAAM,WAAW,CAAC;AAAA,IACxE;AAAA,EACF;AAAA,EAEA,oBAAoB,aAAwD;AAC1E,SAAK,cAAc,KAAK,YAAY,OAAO,WAAW;AAAA,EACxD;AAAA,EAEA,QAAQ,SAAqC;AAC3C,eAAW,SAAS,KAAK,QAAQ;AAC/B,UAAI,MAAM,KAAK,OAAO,GAAG;AACvB,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,gBAAgB,SAA2B;AACzC,UAAM,KAAc,CAAC;AACrB,UAAM,MAAM,IAAI,IAAI,QAAQ,OAAO,KAAK,kBAAkB;AAC1D,eAAW,SAAS,KAAK,QAAQ;AAC/B,UAAI,MAAM,SAAS,IAAI,QAAQ,GAAG;AAChC,WAAG,KAAK,KAAK;AAAA,MACf;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,iBAAiB,SAAkB,UAAoB;AACrD,UAAM,QAAQ,KAAK,QAAQ,OAAO;AAClC,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AACA,UAAM,QAAQ,MAAM,MAAM,OAAO;AACjC,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AAEA,YAAQ,SAAS,MAAM;AACvB,WAAO,IAAI,cAAc,OAAO,SAAS,UAAU,KAAK,WAAW;AAAA,EACrE;AACF;","names":["path"]}
|