@koa/router 15.1.1 → 15.1.2

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/index.d.mts CHANGED
@@ -172,6 +172,7 @@ declare class Layer<StateT = DefaultState, ContextT = DefaultContext, BodyT = un
172
172
  private _reconfigurePathMatching;
173
173
  }
174
174
 
175
+ type RouterInstance<StateT = koa.DefaultState, ContextT = koa.DefaultContext> = RouterImplementation<StateT, ContextT>;
175
176
  /**
176
177
  * Middleware with router property
177
178
  */
@@ -181,7 +182,7 @@ type RouterComposedMiddleware<StateT = koa.DefaultState, ContextT = koa.DefaultC
181
182
  /**
182
183
  * @module koa-router
183
184
  */
184
- declare class Router<StateT = koa.DefaultState, ContextT = koa.DefaultContext> {
185
+ declare class RouterImplementation<StateT = koa.DefaultState, ContextT = koa.DefaultContext> {
185
186
  opts: RouterOptions;
186
187
  methods: string[];
187
188
  exclusive: boolean;
@@ -642,7 +643,8 @@ interface RouterConstructor {
642
643
  url(path: string, ...parameters: unknown[]): string;
643
644
  readonly prototype: Router;
644
645
  }
645
- declare const RouterExport: RouterConstructor;
646
+ type Router<StateT = koa.DefaultState, ContextT = koa.DefaultContext> = RouterInstance<StateT, ContextT>;
647
+ declare const Router: RouterConstructor;
646
648
 
647
649
  /**
648
650
  * Type definitions for @koa/router
@@ -738,7 +740,7 @@ type RouterParameterContext<StateT = DefaultState, ContextT = DefaultContext> =
738
740
  /**
739
741
  * Router instance
740
742
  */
741
- router: Router<StateT, ContextT>;
743
+ router: RouterInstance<StateT, ContextT>;
742
744
  /**
743
745
  * Matched route path (internal)
744
746
  */
@@ -831,13 +833,13 @@ type RouterOptionsWithMethods<M extends string = string> = Omit<RouterOptions, '
831
833
  * Type for a dynamic HTTP method function on Router
832
834
  */
833
835
  type RouterMethodFunction<StateT = DefaultState, ContextT = DefaultContext> = {
834
- <T = {}, U = {}, B = unknown>(name: string, path: string | RegExp, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): Router<StateT, ContextT>;
835
- <T = {}, U = {}, B = unknown>(path: string | RegExp | Array<string | RegExp>, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): Router<StateT, ContextT>;
836
+ <T = {}, U = {}, B = unknown>(name: string, path: string | RegExp, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): RouterInstance<StateT, ContextT>;
837
+ <T = {}, U = {}, B = unknown>(path: string | RegExp | Array<string | RegExp>, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): RouterInstance<StateT, ContextT>;
836
838
  };
837
839
  /**
838
840
  * Router with additional HTTP methods based on the methods option.
839
841
  * Use createRouter() factory function for automatic type inference.
840
842
  */
841
- type RouterWithMethods<M extends string, StateT = DefaultState, ContextT = DefaultContext> = Router<StateT, ContextT> & Record<Lowercase<M>, RouterMethodFunction<StateT, ContextT>>;
843
+ type RouterWithMethods<M extends string, StateT = DefaultState, ContextT = DefaultContext> = RouterInstance<StateT, ContextT> & Record<Lowercase<M>, RouterMethodFunction<StateT, ContextT>>;
842
844
 
843
- export { type AllowedMethodsOptions, type HttpMethod, Layer, type LayerOptions, type MatchResult, RouterExport as Router, type RouterContext, Router as RouterInstance, type RouterMethodFunction, type RouterMiddleware, type RouterOptions, type RouterOptionsWithMethods, type RouterParameterMiddleware, type RouterWithMethods, type UrlOptions, RouterExport as default };
845
+ export { type AllowedMethodsOptions, type HttpMethod, Layer, type LayerOptions, type MatchResult, Router, type RouterContext, type RouterInstance, type RouterMethodFunction, type RouterMiddleware, type RouterOptions, type RouterOptionsWithMethods, type RouterParameterMiddleware, type RouterWithMethods, type UrlOptions, Router as default };
package/dist/index.d.ts CHANGED
@@ -172,6 +172,7 @@ declare class Layer<StateT = DefaultState, ContextT = DefaultContext, BodyT = un
172
172
  private _reconfigurePathMatching;
173
173
  }
174
174
 
175
+ type RouterInstance<StateT = koa.DefaultState, ContextT = koa.DefaultContext> = RouterImplementation<StateT, ContextT>;
175
176
  /**
176
177
  * Middleware with router property
177
178
  */
@@ -181,7 +182,7 @@ type RouterComposedMiddleware<StateT = koa.DefaultState, ContextT = koa.DefaultC
181
182
  /**
182
183
  * @module koa-router
183
184
  */
184
- declare class Router<StateT = koa.DefaultState, ContextT = koa.DefaultContext> {
185
+ declare class RouterImplementation<StateT = koa.DefaultState, ContextT = koa.DefaultContext> {
185
186
  opts: RouterOptions;
186
187
  methods: string[];
187
188
  exclusive: boolean;
@@ -642,7 +643,8 @@ interface RouterConstructor {
642
643
  url(path: string, ...parameters: unknown[]): string;
643
644
  readonly prototype: Router;
644
645
  }
645
- declare const RouterExport: RouterConstructor;
646
+ type Router<StateT = koa.DefaultState, ContextT = koa.DefaultContext> = RouterInstance<StateT, ContextT>;
647
+ declare const Router: RouterConstructor;
646
648
 
647
649
  /**
648
650
  * Type definitions for @koa/router
@@ -738,7 +740,7 @@ type RouterParameterContext<StateT = DefaultState, ContextT = DefaultContext> =
738
740
  /**
739
741
  * Router instance
740
742
  */
741
- router: Router<StateT, ContextT>;
743
+ router: RouterInstance<StateT, ContextT>;
742
744
  /**
743
745
  * Matched route path (internal)
744
746
  */
@@ -831,13 +833,13 @@ type RouterOptionsWithMethods<M extends string = string> = Omit<RouterOptions, '
831
833
  * Type for a dynamic HTTP method function on Router
832
834
  */
833
835
  type RouterMethodFunction<StateT = DefaultState, ContextT = DefaultContext> = {
834
- <T = {}, U = {}, B = unknown>(name: string, path: string | RegExp, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): Router<StateT, ContextT>;
835
- <T = {}, U = {}, B = unknown>(path: string | RegExp | Array<string | RegExp>, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): Router<StateT, ContextT>;
836
+ <T = {}, U = {}, B = unknown>(name: string, path: string | RegExp, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): RouterInstance<StateT, ContextT>;
837
+ <T = {}, U = {}, B = unknown>(path: string | RegExp | Array<string | RegExp>, ...middleware: Array<RouterMiddleware<StateT & T, ContextT & U, B>>): RouterInstance<StateT, ContextT>;
836
838
  };
837
839
  /**
838
840
  * Router with additional HTTP methods based on the methods option.
839
841
  * Use createRouter() factory function for automatic type inference.
840
842
  */
841
- type RouterWithMethods<M extends string, StateT = DefaultState, ContextT = DefaultContext> = Router<StateT, ContextT> & Record<Lowercase<M>, RouterMethodFunction<StateT, ContextT>>;
843
+ type RouterWithMethods<M extends string, StateT = DefaultState, ContextT = DefaultContext> = RouterInstance<StateT, ContextT> & Record<Lowercase<M>, RouterMethodFunction<StateT, ContextT>>;
842
844
 
843
- export { type AllowedMethodsOptions, type HttpMethod, Layer, type LayerOptions, type MatchResult, RouterExport as Router, type RouterContext, Router as RouterInstance, type RouterMethodFunction, type RouterMiddleware, type RouterOptions, type RouterOptionsWithMethods, type RouterParameterMiddleware, type RouterWithMethods, type UrlOptions, RouterExport as default };
845
+ export { type AllowedMethodsOptions, type HttpMethod, Layer, type LayerOptions, type MatchResult, Router, type RouterContext, type RouterInstance, type RouterMethodFunction, type RouterMiddleware, type RouterOptions, type RouterOptionsWithMethods, type RouterParameterMiddleware, type RouterWithMethods, type UrlOptions, Router as default };
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- Router: () => RouterExport,
33
+ Router: () => Router,
34
34
  default: () => router_default
35
35
  });
36
36
  module.exports = __toCommonJS(index_exports);
@@ -594,7 +594,7 @@ var debug = (0, import_debug.default)("koa-router");
594
594
 
595
595
  // src/router.ts
596
596
  var httpMethods = getAllHttpMethods();
597
- var Router = class {
597
+ var RouterImplementation = class {
598
598
  opts;
599
599
  methods;
600
600
  exclusive;
@@ -1419,12 +1419,12 @@ var Router = class {
1419
1419
  return this._registerMethod("options", ...arguments_);
1420
1420
  }
1421
1421
  };
1422
- var RouterExport = Router;
1423
- var router_default = RouterExport;
1422
+ var Router = RouterImplementation;
1423
+ var router_default = Router;
1424
1424
  for (const httpMethod of httpMethods) {
1425
- const isAlreadyDefined = COMMON_HTTP_METHODS.includes(httpMethod) || httpMethod in Router.prototype;
1425
+ const isAlreadyDefined = COMMON_HTTP_METHODS.includes(httpMethod) || httpMethod in RouterImplementation.prototype;
1426
1426
  if (!isAlreadyDefined) {
1427
- Object.defineProperty(Router.prototype, httpMethod, {
1427
+ Object.defineProperty(RouterImplementation.prototype, httpMethod, {
1428
1428
  value: function(...arguments_) {
1429
1429
  return this._registerMethod(httpMethod, ...arguments_);
1430
1430
  },
package/dist/index.mjs CHANGED
@@ -557,7 +557,7 @@ var debug = debugModule("koa-router");
557
557
 
558
558
  // src/router.ts
559
559
  var httpMethods = getAllHttpMethods();
560
- var Router = class {
560
+ var RouterImplementation = class {
561
561
  opts;
562
562
  methods;
563
563
  exclusive;
@@ -1382,12 +1382,12 @@ var Router = class {
1382
1382
  return this._registerMethod("options", ...arguments_);
1383
1383
  }
1384
1384
  };
1385
- var RouterExport = Router;
1386
- var router_default = RouterExport;
1385
+ var Router = RouterImplementation;
1386
+ var router_default = Router;
1387
1387
  for (const httpMethod of httpMethods) {
1388
- const isAlreadyDefined = COMMON_HTTP_METHODS.includes(httpMethod) || httpMethod in Router.prototype;
1388
+ const isAlreadyDefined = COMMON_HTTP_METHODS.includes(httpMethod) || httpMethod in RouterImplementation.prototype;
1389
1389
  if (!isAlreadyDefined) {
1390
- Object.defineProperty(Router.prototype, httpMethod, {
1390
+ Object.defineProperty(RouterImplementation.prototype, httpMethod, {
1391
1391
  value: function(...arguments_) {
1392
1392
  return this._registerMethod(httpMethod, ...arguments_);
1393
1393
  },
@@ -1398,6 +1398,6 @@ for (const httpMethod of httpMethods) {
1398
1398
  }
1399
1399
  }
1400
1400
  export {
1401
- RouterExport as Router,
1401
+ Router,
1402
1402
  router_default as default
1403
1403
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@koa/router",
3
3
  "description": "Router middleware for koa. Maintained by Forward Email and Lad.",
4
- "version": "15.1.1",
4
+ "version": "15.1.2",
5
5
  "author": "Alex Mingoia <talk@alexmingoia.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/koajs/router/issues",
@@ -35,18 +35,18 @@
35
35
  "path-to-regexp": "^8.3.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@commitlint/cli": "^20.2.0",
39
- "@commitlint/config-conventional": "^20.2.0",
38
+ "@commitlint/cli": "^20.3.0",
39
+ "@commitlint/config-conventional": "^20.3.0",
40
40
  "@koa/bodyparser": "^6.0.0",
41
41
  "@types/debug": "^4.1.12",
42
- "@types/jsonwebtoken": "^9.0.7",
42
+ "@types/jsonwebtoken": "^9.0.10",
43
43
  "@types/koa": "^3.0.1",
44
44
  "@types/node": "^25.0.3",
45
45
  "@types/supertest": "^6.0.3",
46
- "@typescript-eslint/eslint-plugin": "^8.50.0",
47
- "@typescript-eslint/parser": "^8.50.0",
46
+ "@typescript-eslint/eslint-plugin": "^8.51.0",
47
+ "@typescript-eslint/parser": "^8.51.0",
48
48
  "c8": "^10.1.3",
49
- "chalk": "^5.4.1",
49
+ "chalk": "^5.6.2",
50
50
  "eslint": "^9.39.2",
51
51
  "eslint-plugin-unicorn": "^62.0.0",
52
52
  "husky": "^9.1.7",
@@ -108,7 +108,7 @@
108
108
  "lint": "npm run lint:ts",
109
109
  "test:core": "TS_NODE_PROJECT=tsconfig.ts-node.json node --require ts-node/register --test test/*.test.ts test/**/*.test.ts",
110
110
  "test:recipes": "TS_NODE_PROJECT=tsconfig.recipes.json node --require ts-node/register --test recipes/**/*.test.ts",
111
- "pretest:all": "npm run lint",
111
+ "pretest:all": "npm run lint && npm run build",
112
112
  "test:all": "TS_NODE_PROJECT=tsconfig.ts-node.json node --require ts-node/register --test test/*.test.ts test/**/*.test.ts recipes/**/*.test.ts",
113
113
  "test:coverage": "c8 npm run test:all",
114
114
  "ts:check": "tsc --noEmit --project tsconfig.typecheck.json",