clear-router 2.8.3 → 2.8.5
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/ClearRequest.d.cts +5 -5
- package/dist/ClearRequest.d.mts +1 -1
- package/dist/Controller.d.mts +1 -1
- package/dist/ResourceRouteSelection.d.cts +3 -3
- package/dist/ResourceRoutes.cjs +1 -1
- package/dist/ResourceRoutes.d.cts +4 -4
- package/dist/ResourceRoutes.d.mts +1 -1
- package/dist/ResourceRoutes.mjs +1 -1
- package/dist/Route.d.cts +4 -4
- package/dist/Route.d.mts +1 -1
- package/dist/RouteGroup.cjs +36 -6
- package/dist/RouteGroup.d.cts +14 -5
- package/dist/RouteGroup.d.mts +12 -3
- package/dist/RouteGroup.mjs +36 -6
- package/dist/core/CoreRouter.cjs +2 -2
- package/dist/core/CoreRouter.d.cts +4 -4
- package/dist/core/CoreRouter.d.mts +1 -1
- package/dist/core/CoreRouter.mjs +2 -2
- package/dist/core/Request.d.cts +1 -1
- package/dist/core/Request.d.mts +2 -2
- package/dist/core/bindings.d.cts +6 -1
- package/dist/core/helpers.d.cts +1 -1
- package/dist/core/helpers.d.mts +1 -1
- package/dist/core/index.cjs +9 -0
- package/dist/core/index.mjs +2 -2
- package/dist/core/plugins.d.cts +2 -2
- package/dist/core/plugins.d.mts +1 -1
- package/dist/decorators/setup.d.mts +1 -0
- package/dist/express/router.d.cts +15 -15
- package/dist/express/router.d.mts +15 -15
- package/dist/fastify/router.d.cts +15 -15
- package/dist/fastify/router.d.mts +15 -15
- package/dist/h3/router.d.cts +15 -15
- package/dist/h3/router.d.mts +15 -15
- package/dist/hono/router.d.cts +15 -15
- package/dist/hono/router.d.mts +15 -15
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/koa/router.d.cts +17 -17
- package/dist/koa/router.d.mts +17 -17
- package/dist/types/basic.cjs +0 -0
- package/dist/types/basic.d.cts +8 -3
- package/dist/types/basic.d.mts +5 -4
- package/dist/types/express.cjs +0 -0
- package/dist/types/express.d.cts +36 -2
- package/dist/types/express.d.mts +3 -3
- package/dist/types/fastify.cjs +0 -0
- package/dist/types/fastify.d.cts +15 -3
- package/dist/types/fastify.d.mts +3 -3
- package/dist/types/h3.cjs +0 -0
- package/dist/types/h3.d.cts +42 -5
- package/dist/types/h3.d.mts +8 -6
- package/dist/types/hono.cjs +0 -0
- package/dist/types/hono.d.cts +18 -3
- package/dist/types/hono.d.mts +4 -3
- package/dist/types/koa.cjs +0 -0
- package/dist/types/koa.d.cts +21 -2
- package/dist/types/koa.d.mts +4 -3
- package/package.json +25 -7
- package/dist/Route-tq-rge1g.d.mts +0 -136
- package/dist/types/index.d.mts +0 -1
package/dist/types/h3.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.mjs";
|
|
1
2
|
import { ClearHttpContext } from "../Contracts.mjs";
|
|
2
3
|
import { Response as Response$1 } from "../core/Response.mjs";
|
|
3
|
-
import { ClassMiddleware, ControllerHandler } from "./basic.mjs";
|
|
4
4
|
import { Request } from "../core/Request.mjs";
|
|
5
|
-
import { EventHandlerRequest, H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
5
|
+
import { EventHandlerRequest, H3, H3Event, Middleware as Middleware$1, TypedServerRequest } from "h3";
|
|
6
6
|
|
|
7
7
|
//#region src/types/h3.d.ts
|
|
8
8
|
type H3App = Omit<H3, 'fetch'> & {
|
|
9
9
|
fetch: (request: TypedServerRequest<EventHandlerRequest>) => Promise<Response>;
|
|
10
10
|
};
|
|
11
|
+
type MaybePromise<T = unknown> = T | Promise<T>;
|
|
11
12
|
interface HttpRequest extends TypedServerRequest<EventHandlerRequest> {
|
|
12
13
|
getBody: () => Record<string, any>;
|
|
13
14
|
}
|
|
@@ -36,11 +37,12 @@ req: Request) => any | Promise<any>;
|
|
|
36
37
|
/**
|
|
37
38
|
* Handler can be either a function or controller reference
|
|
38
39
|
*/
|
|
39
|
-
type Handler = RouteHandler | ControllerHandler
|
|
40
|
+
type Handler<T = any> = RouteHandler | ControllerHandler<T>;
|
|
41
|
+
type NextFunction = () => MaybePromise<unknown | undefined>;
|
|
40
42
|
/**
|
|
41
43
|
* Middleware function type
|
|
42
44
|
*/
|
|
43
|
-
type MiddlewareFunction = Middleware;
|
|
44
|
-
type Middleware
|
|
45
|
+
type MiddlewareFunction = Middleware$1;
|
|
46
|
+
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
45
47
|
//#endregion
|
|
46
|
-
export { H3App, Handler, HttpContext,
|
|
48
|
+
export { H3App, Handler, HttpContext, HttpRequest, MaybePromise, Middleware, MiddlewareFunction, NextFunction, RouteHandler };
|
|
File without changes
|
package/dist/types/hono.d.cts
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { ClassMiddleware } from "./basic.cjs";
|
|
2
|
-
import {
|
|
1
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.cjs";
|
|
2
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
3
|
+
import { Response } from "../core/Response.cjs";
|
|
4
|
+
import { Request } from "../core/Request.cjs";
|
|
5
|
+
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
6
|
|
|
4
7
|
//#region src/types/hono.d.ts
|
|
8
|
+
type RequestWithGetBody = HonoRequest & {
|
|
9
|
+
getBody: () => Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
interface HttpContext extends Context, ClearHttpContext {
|
|
12
|
+
req: RequestWithGetBody;
|
|
13
|
+
clearRequest: Request;
|
|
14
|
+
clearResponse: Response;
|
|
15
|
+
}
|
|
16
|
+
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
17
|
+
type Handler<T = any> = RouteHandler | ControllerHandler<T>;
|
|
18
|
+
type NextFunction = () => Promise<void>;
|
|
5
19
|
type MiddlewareFunction = MiddlewareHandler;
|
|
6
20
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
21
|
+
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: MiddlewareFunction[]) => any };
|
|
7
22
|
//#endregion
|
|
8
|
-
export { Middleware };
|
|
23
|
+
export { Handler, HonoApp, HttpContext, Middleware, MiddlewareFunction, NextFunction, RequestWithGetBody, RouteHandler };
|
package/dist/types/hono.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.mjs";
|
|
1
2
|
import { ClearHttpContext } from "../Contracts.mjs";
|
|
2
3
|
import { Response } from "../core/Response.mjs";
|
|
3
|
-
import { ClassMiddleware, ControllerHandler } from "./basic.mjs";
|
|
4
4
|
import { Request } from "../core/Request.mjs";
|
|
5
5
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
6
6
|
|
|
@@ -14,9 +14,10 @@ interface HttpContext extends Context, ClearHttpContext {
|
|
|
14
14
|
clearResponse: Response;
|
|
15
15
|
}
|
|
16
16
|
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
17
|
-
type Handler = RouteHandler | ControllerHandler
|
|
17
|
+
type Handler<T = any> = RouteHandler | ControllerHandler<T>;
|
|
18
|
+
type NextFunction = () => Promise<void>;
|
|
18
19
|
type MiddlewareFunction = MiddlewareHandler;
|
|
19
20
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
20
21
|
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: MiddlewareFunction[]) => any };
|
|
21
22
|
//#endregion
|
|
22
|
-
export { Handler, HonoApp, HttpContext, Middleware };
|
|
23
|
+
export { Handler, HonoApp, HttpContext, Middleware, MiddlewareFunction, NextFunction, RequestWithGetBody, RouteHandler };
|
|
File without changes
|
package/dist/types/koa.d.cts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import { ClassMiddleware } from "./basic.cjs";
|
|
1
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.cjs";
|
|
2
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
3
|
+
import { Response } from "../core/Response.cjs";
|
|
4
|
+
import { Request } from "../core/Request.cjs";
|
|
2
5
|
import Koa from "koa";
|
|
6
|
+
import Router from "@koa/router";
|
|
3
7
|
|
|
4
8
|
//#region src/types/koa.d.ts
|
|
9
|
+
interface RequestWithGetBody extends Koa.Request {
|
|
10
|
+
getBody: () => Record<string, any>;
|
|
11
|
+
body?: any;
|
|
12
|
+
}
|
|
13
|
+
interface HttpContext extends Koa.Context, ClearHttpContext {
|
|
14
|
+
request: RequestWithGetBody;
|
|
15
|
+
clearRequest: Request;
|
|
16
|
+
clearResponse: Response;
|
|
17
|
+
params: Record<string, any>;
|
|
18
|
+
query: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
21
|
+
type Handler<T = any> = RouteHandler | ControllerHandler<T>;
|
|
22
|
+
type NextFunction = Koa.Next;
|
|
5
23
|
type MiddlewareFunction = Koa.Middleware<any, any>;
|
|
6
24
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
25
|
+
type KoaRouterApp = Router<any, any>;
|
|
7
26
|
//#endregion
|
|
8
|
-
export { Middleware };
|
|
27
|
+
export { Handler, HttpContext, KoaRouterApp, Middleware, NextFunction, RequestWithGetBody, RouteHandler };
|
package/dist/types/koa.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.mjs";
|
|
1
2
|
import { ClearHttpContext } from "../Contracts.mjs";
|
|
2
3
|
import { Response } from "../core/Response.mjs";
|
|
3
|
-
import { ClassMiddleware, ControllerHandler } from "./basic.mjs";
|
|
4
4
|
import { Request } from "../core/Request.mjs";
|
|
5
5
|
import Koa from "koa";
|
|
6
6
|
import Router from "@koa/router";
|
|
@@ -18,9 +18,10 @@ interface HttpContext extends Koa.Context, ClearHttpContext {
|
|
|
18
18
|
query: Record<string, any>;
|
|
19
19
|
}
|
|
20
20
|
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
21
|
-
type Handler = RouteHandler | ControllerHandler
|
|
21
|
+
type Handler<T = any> = RouteHandler | ControllerHandler<T>;
|
|
22
|
+
type NextFunction = Koa.Next;
|
|
22
23
|
type MiddlewareFunction = Koa.Middleware<any, any>;
|
|
23
24
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
24
25
|
type KoaRouterApp = Router<any, any>;
|
|
25
26
|
//#endregion
|
|
26
|
-
export { Handler, HttpContext, KoaRouterApp, Middleware };
|
|
27
|
+
export { Handler, HttpContext, KoaRouterApp, Middleware, NextFunction, RequestWithGetBody, RouteHandler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clear-router",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.5",
|
|
4
4
|
"description": "Laravel-style routing for Node.js with support for Express, H3, Fastify, Hono, and Koa, including CommonJS, ESM, and TypeScript support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"h3",
|
|
@@ -68,12 +68,30 @@
|
|
|
68
68
|
"import": "./dist/koa/index.mjs",
|
|
69
69
|
"require": "./dist/koa/index.cjs"
|
|
70
70
|
},
|
|
71
|
-
"./types/basic":
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"./types/
|
|
76
|
-
|
|
71
|
+
"./types/basic": {
|
|
72
|
+
"import": "./dist/types/basic.mjs",
|
|
73
|
+
"require": "./dist/types/basic.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./types/express": {
|
|
76
|
+
"import": "./dist/types/express.mjs",
|
|
77
|
+
"require": "./dist/types/express.cjs"
|
|
78
|
+
},
|
|
79
|
+
"./types/fastify": {
|
|
80
|
+
"import": "./dist/types/fastify.mjs",
|
|
81
|
+
"require": "./dist/types/fastify.cjs"
|
|
82
|
+
},
|
|
83
|
+
"./types/h3": {
|
|
84
|
+
"import": "./dist/types/h3.mjs",
|
|
85
|
+
"require": "./dist/types/h3.cjs"
|
|
86
|
+
},
|
|
87
|
+
"./types/hono": {
|
|
88
|
+
"import": "./dist/types/hono.mjs",
|
|
89
|
+
"require": "./dist/types/hono.cjs"
|
|
90
|
+
},
|
|
91
|
+
"./types/koa": {
|
|
92
|
+
"import": "./dist/types/koa.mjs",
|
|
93
|
+
"require": "./dist/types/koa.cjs"
|
|
94
|
+
},
|
|
77
95
|
"./package.json": "./package.json"
|
|
78
96
|
},
|
|
79
97
|
"files": [
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { Middleware } from "./types/express.mjs";
|
|
2
|
-
import { Middleware as Middleware$1 } from "./types/fastify.mjs";
|
|
3
|
-
import { Middleware as Middleware$2 } from "./types/h3.mjs";
|
|
4
|
-
import { Middleware as Middleware$3 } from "./types/hono.mjs";
|
|
5
|
-
import { Middleware as Middleware$4 } from "./types/koa.mjs";
|
|
6
|
-
import { HttpMethod, RequestData } from "./types/basic.mjs";
|
|
7
|
-
|
|
8
|
-
//#region src/Contracts.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* HTTP context passed to route handlers
|
|
11
|
-
*/
|
|
12
|
-
interface ClearHttpContext {}
|
|
13
|
-
interface RouteParameter {
|
|
14
|
-
name: string;
|
|
15
|
-
field?: string;
|
|
16
|
-
optional: boolean;
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/core/Request.d.ts
|
|
20
|
-
declare class Request<X = any, M = any> extends ClearRequest<X, M> {
|
|
21
|
-
original?: any;
|
|
22
|
-
method: string;
|
|
23
|
-
path: string;
|
|
24
|
-
url: string;
|
|
25
|
-
headers: Headers | Record<string, any>;
|
|
26
|
-
constructor(init?: Partial<Request<X, M>> & {
|
|
27
|
-
body?: RequestData;
|
|
28
|
-
query?: RequestData;
|
|
29
|
-
params?: RequestData;
|
|
30
|
-
route?: Route<X, M>;
|
|
31
|
-
});
|
|
32
|
-
getBody(): RequestData;
|
|
33
|
-
header(name: string): string;
|
|
34
|
-
param(name: string): any;
|
|
35
|
-
input(name: string): any;
|
|
36
|
-
is(method: HttpMethod | string): boolean;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/core/Response.d.ts
|
|
40
|
-
declare class Response {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
body: any;
|
|
43
|
-
headers: Headers;
|
|
44
|
-
sent: boolean;
|
|
45
|
-
statusCode: number;
|
|
46
|
-
statusText: string;
|
|
47
|
-
constructor(init?: Partial<Response | globalThis.Response>);
|
|
48
|
-
status(code: number): this;
|
|
49
|
-
setStatusText(text: string): this;
|
|
50
|
-
code(code: number): this;
|
|
51
|
-
setHeader(name: string, value: string): this;
|
|
52
|
-
header(name: string, value: string): this;
|
|
53
|
-
set(name: string, value: string): this;
|
|
54
|
-
type(contentType: string): this;
|
|
55
|
-
send(body?: any): this;
|
|
56
|
-
json(body: any): this;
|
|
57
|
-
html(body: string): this;
|
|
58
|
-
text(body: string): this;
|
|
59
|
-
noContent(): this;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/ClearRequest.d.ts
|
|
63
|
-
declare class ClearRequest<X = any, M = Middleware$2 | Middleware | Middleware$1 | Middleware$3 | Middleware$4> {
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
/**
|
|
66
|
-
* @param body - Parsed request body
|
|
67
|
-
*/
|
|
68
|
-
body: RequestData;
|
|
69
|
-
/**
|
|
70
|
-
* @param query - Parsed query parameters
|
|
71
|
-
*/
|
|
72
|
-
query: RequestData;
|
|
73
|
-
/**
|
|
74
|
-
* @param params - Parsed route parameters
|
|
75
|
-
*/
|
|
76
|
-
params: RequestData;
|
|
77
|
-
route: Route<X, M>;
|
|
78
|
-
constructor(init?: Partial<ClearRequest>);
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/Route.d.ts
|
|
82
|
-
/**
|
|
83
|
-
* @class clear-router Route
|
|
84
|
-
* @description A route describes a single enpoint on clear-router
|
|
85
|
-
* @author 3m1n3nc3
|
|
86
|
-
* @repository https://github.com/arkstack-tmp/clear-router
|
|
87
|
-
*/
|
|
88
|
-
declare class Route<X = any, M = Middleware$2 | Middleware, H = any> {
|
|
89
|
-
ctx: X;
|
|
90
|
-
body: RequestData;
|
|
91
|
-
query: RequestData;
|
|
92
|
-
params: RequestData;
|
|
93
|
-
clearRequest: ClearRequest;
|
|
94
|
-
methods: HttpMethod[];
|
|
95
|
-
path: string;
|
|
96
|
-
registrationPaths: string[];
|
|
97
|
-
parameters: RouteParameter[];
|
|
98
|
-
routeName?: string;
|
|
99
|
-
handler: H;
|
|
100
|
-
middlewares: M[];
|
|
101
|
-
controllerName?: string;
|
|
102
|
-
actionName?: string;
|
|
103
|
-
handlerType: 'function' | 'controller';
|
|
104
|
-
middlewareCount: number;
|
|
105
|
-
constructor(methods: HttpMethod[], path: string, handler: H, middlewares?: M[], options?: {
|
|
106
|
-
registrationPaths?: string[];
|
|
107
|
-
parameters?: RouteParameter[];
|
|
108
|
-
onName?: (name: string, route: Route<X, M, H>, previousName?: string) => void;
|
|
109
|
-
normalizeMiddleware?: (middleware: M) => M;
|
|
110
|
-
});
|
|
111
|
-
private onName?;
|
|
112
|
-
private normalizeMiddleware?;
|
|
113
|
-
/**
|
|
114
|
-
* Set the route name
|
|
115
|
-
*
|
|
116
|
-
* @param name
|
|
117
|
-
* @returns
|
|
118
|
-
*/
|
|
119
|
-
name(name: string): this;
|
|
120
|
-
/**
|
|
121
|
-
* Register one or more middleware that will be executed before the route.
|
|
122
|
-
*
|
|
123
|
-
* @param middlewares
|
|
124
|
-
* @returns
|
|
125
|
-
*/
|
|
126
|
-
middleware(middlewares: M[] | M): this;
|
|
127
|
-
/**
|
|
128
|
-
* Get the path generated and accessible by this route
|
|
129
|
-
*
|
|
130
|
-
* @param params
|
|
131
|
-
* @returns
|
|
132
|
-
*/
|
|
133
|
-
toPath(params?: RequestData): string;
|
|
134
|
-
}
|
|
135
|
-
//#endregion
|
|
136
|
-
export { ClearHttpContext as i, Response as n, Request as r, Route as t };
|
package/dist/types/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { ApiResourceMiddleware, ClassMiddleware, ControllerHandler, FileImporter, HttpMethod, MaybePromise, MiddlewareClass, MiddlewareHandle, MiddlewareInstance, RequestData, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions, RouteGroupCallback, RouteGroupCondition, RouteGroupContext, RouteGroupEntry, RouteGroupOptions, RouteGroupSource, RouterConfig } from "./basic.mjs";
|