itty-router 4.0.2 → 4.0.3

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/Router.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export declare type GenericTraps = {
1
+ export type GenericTraps = {
2
2
  [key: string]: any;
3
3
  };
4
- export declare type RequestLike = {
4
+ export type RequestLike = {
5
5
  method: string;
6
6
  url: string;
7
7
  } & GenericTraps;
8
- export declare type IRequestStrict = {
8
+ export type IRequestStrict = {
9
9
  method: string;
10
10
  url: string;
11
11
  route: string;
@@ -17,22 +17,22 @@ export declare type IRequestStrict = {
17
17
  };
18
18
  proxy?: any;
19
19
  } & Request;
20
- export declare type IRequest = IRequestStrict & GenericTraps;
21
- export declare type RouterOptions = {
20
+ export type IRequest = IRequestStrict & GenericTraps;
21
+ export type RouterOptions = {
22
22
  base?: string;
23
23
  routes?: RouteEntry[];
24
24
  };
25
- export declare type RouteHandler<I = IRequest, A extends any[] = any[]> = {
25
+ export type RouteHandler<I = IRequest, A extends any[] = any[]> = {
26
26
  (request: I, ...args: A): any;
27
27
  };
28
- export declare type RouteEntry = [string, RegExp, RouteHandler[], string];
29
- export declare type Route = <RequestType = IRequest, Args extends any[] = any[], RT = RouterType>(path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RT;
30
- export declare type UniversalRoute<RequestType = IRequest, Args extends any[] = any[]> = (path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RouterType<UniversalRoute<RequestType, Args>, Args>;
31
- declare type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
32
- export declare type CustomRoutes<R = Route> = {
28
+ export type RouteEntry = [string, RegExp, RouteHandler[], string];
29
+ export type Route = <RequestType = IRequest, Args extends any[] = any[], RT = RouterType>(path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RT;
30
+ export type UniversalRoute<RequestType = IRequest, Args extends any[] = any[]> = (path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RouterType<UniversalRoute<RequestType, Args>, Args>;
31
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
32
+ export type CustomRoutes<R = Route> = {
33
33
  [key: string]: R;
34
34
  };
35
- export declare type RouterType<R = Route, Args extends any[] = any[]> = {
35
+ export type RouterType<R = Route, Args extends any[] = any[]> = {
36
36
  __proto__: RouterType<R>;
37
37
  routes: RouteEntry[];
38
38
  handle: <A extends any[] = Args>(request: RequestLike, ...extra: Equal<R, Args> extends true ? A : Args) => Promise<any>;
package/StatusError.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare type StatusErrorObject = {
1
+ type StatusErrorObject = {
2
2
  error?: string;
3
3
  [key: string]: any;
4
4
  };
package/cjs/Router.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export declare type GenericTraps = {
1
+ export type GenericTraps = {
2
2
  [key: string]: any;
3
3
  };
4
- export declare type RequestLike = {
4
+ export type RequestLike = {
5
5
  method: string;
6
6
  url: string;
7
7
  } & GenericTraps;
8
- export declare type IRequestStrict = {
8
+ export type IRequestStrict = {
9
9
  method: string;
10
10
  url: string;
11
11
  route: string;
@@ -17,22 +17,22 @@ export declare type IRequestStrict = {
17
17
  };
18
18
  proxy?: any;
19
19
  } & Request;
20
- export declare type IRequest = IRequestStrict & GenericTraps;
21
- export declare type RouterOptions = {
20
+ export type IRequest = IRequestStrict & GenericTraps;
21
+ export type RouterOptions = {
22
22
  base?: string;
23
23
  routes?: RouteEntry[];
24
24
  };
25
- export declare type RouteHandler<I = IRequest, A extends any[] = any[]> = {
25
+ export type RouteHandler<I = IRequest, A extends any[] = any[]> = {
26
26
  (request: I, ...args: A): any;
27
27
  };
28
- export declare type RouteEntry = [string, RegExp, RouteHandler[], string];
29
- export declare type Route = <RequestType = IRequest, Args extends any[] = any[], RT = RouterType>(path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RT;
30
- export declare type UniversalRoute<RequestType = IRequest, Args extends any[] = any[]> = (path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RouterType<UniversalRoute<RequestType, Args>, Args>;
31
- declare type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
32
- export declare type CustomRoutes<R = Route> = {
28
+ export type RouteEntry = [string, RegExp, RouteHandler[], string];
29
+ export type Route = <RequestType = IRequest, Args extends any[] = any[], RT = RouterType>(path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RT;
30
+ export type UniversalRoute<RequestType = IRequest, Args extends any[] = any[]> = (path: string, ...handlers: RouteHandler<RequestType, Args>[]) => RouterType<UniversalRoute<RequestType, Args>, Args>;
31
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
32
+ export type CustomRoutes<R = Route> = {
33
33
  [key: string]: R;
34
34
  };
35
- export declare type RouterType<R = Route, Args extends any[] = any[]> = {
35
+ export type RouterType<R = Route, Args extends any[] = any[]> = {
36
36
  __proto__: RouterType<R>;
37
37
  routes: RouteEntry[];
38
38
  handle: <A extends any[] = Args>(request: RequestLike, ...extra: Equal<R, Args> extends true ? A : Args) => Promise<any>;
@@ -1,4 +1,4 @@
1
- declare type StatusErrorObject = {
1
+ type StatusErrorObject = {
2
2
  error?: string;
3
3
  [key: string]: any;
4
4
  };
package/cjs/error.d.ts CHANGED
@@ -2,7 +2,7 @@ interface ErrorLike extends Error {
2
2
  status?: number;
3
3
  [any: string]: any;
4
4
  }
5
- export declare type ErrorBody = string | object;
5
+ export type ErrorBody = string | object;
6
6
  export interface ErrorFormatter {
7
7
  (statusCode?: number, body?: ErrorBody): Response;
8
8
  (error: ErrorLike): Response;
package/error.d.ts CHANGED
@@ -2,7 +2,7 @@ interface ErrorLike extends Error {
2
2
  status?: number;
3
3
  [any: string]: any;
4
4
  }
5
- export declare type ErrorBody = string | object;
5
+ export type ErrorBody = string | object;
6
6
  export interface ErrorFormatter {
7
7
  (statusCode?: number, body?: ErrorBody): Response;
8
8
  (error: ErrorLike): Response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-router",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -45,36 +45,36 @@
45
45
  },
46
46
  "homepage": "https://itty.dev/itty-router",
47
47
  "devDependencies": {
48
- "@cloudflare/workers-types": "^4.20221111.1",
48
+ "@cloudflare/workers-types": "^4.20230518.0",
49
49
  "@rollup/plugin-multi-entry": "^6.0.0",
50
- "@rollup/plugin-terser": "^0.2.1",
51
- "@rollup/plugin-typescript": "^10.0.1",
50
+ "@rollup/plugin-terser": "^0.4.3",
51
+ "@rollup/plugin-typescript": "^11.1.1",
52
52
  "@skypack/package-check": "^0.2.2",
53
- "@types/node": "^20.2.1",
54
- "@vitejs/plugin-vue": "^2.2.4",
55
- "@vitest/coverage-c8": "^0.24.3",
56
- "@whatwg-node/server": "^0.7.6",
53
+ "@types/node": "^20.2.5",
54
+ "@vitejs/plugin-vue": "^4.2.3",
55
+ "@vitest/coverage-c8": "^0.31.1",
56
+ "@whatwg-node/server": "^0.8.0",
57
57
  "coveralls": "^3.1.1",
58
- "eslint": "^8.11.0",
59
- "eslint-plugin-jest": "^26.1.2",
58
+ "eslint": "^8.41.0",
59
+ "eslint-plugin-jest": "^27.2.1",
60
60
  "fetch-mock": "^9.11.0",
61
- "fs-extra": "^10.0.1",
62
- "globby": "^13.1.3",
63
- "gzip-size": "^6.0.0",
61
+ "fs-extra": "^11.1.1",
62
+ "globby": "^13.1.4",
63
+ "gzip-size": "^7.0.0",
64
64
  "http": "^0.0.1-security",
65
65
  "isomorphic-fetch": "^3.0.0",
66
- "itty-router": "^4.0.0-next.50",
67
- "jsdom": "^20.0.1",
66
+ "itty-router": "^4.0.2",
67
+ "jsdom": "^22.1.0",
68
68
  "npm-run-all": "^4.1.5",
69
- "rimraf": "^3.0.2",
70
- "rollup": "^3.8.1",
69
+ "rimraf": "^5.0.1",
70
+ "rollup": "^3.23.0",
71
71
  "rollup-plugin-bundle-size": "^1.0.3",
72
- "rollup-plugin-multi-input": "^1.3.3",
72
+ "rollup-plugin-multi-input": "^1.4.1",
73
73
  "ts-node": "^10.9.1",
74
- "typescript": "^4.8.4",
75
- "vite": "^2.8.6",
76
- "vitest": "^0.24.3",
77
- "yarn": "^1.22.18",
78
- "yarn-release": "^1.10.3"
74
+ "typescript": "^5.0.4",
75
+ "vite": "^4.3.9",
76
+ "vitest": "^0.31.1",
77
+ "yarn": "^1.22.19",
78
+ "yarn-release": "^1.10.5"
79
79
  }
80
80
  }