clear-router 2.6.0 → 2.6.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/core/index.cjs +1 -1
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.mts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/decorators/setup.cjs +1 -1
- package/dist/decorators/setup.mjs +1 -1
- package/dist/express/index.cjs +1 -1
- package/dist/express/index.d.cts +1 -1
- package/dist/express/index.d.mts +1 -1
- package/dist/express/index.mjs +1 -1
- package/dist/fastify/index.cjs +1 -1
- package/dist/fastify/index.d.cts +1 -18
- package/dist/fastify/index.d.mts +1 -18
- package/dist/fastify/index.mjs +1 -1
- package/dist/h3/index.cjs +1 -1
- package/dist/h3/index.d.cts +1 -1
- package/dist/h3/index.d.mts +1 -1
- package/dist/h3/index.mjs +1 -1
- package/dist/hono/index.cjs +1 -1
- package/dist/hono/index.d.cts +1 -16
- package/dist/hono/index.d.mts +1 -16
- package/dist/hono/index.mjs +1 -1
- package/dist/index.cjs +48 -2
- package/dist/index.d.cts +45 -4
- package/dist/index.d.mts +45 -4
- package/dist/index.mjs +48 -2
- package/dist/koa/index.cjs +1 -1
- package/dist/koa/index.d.cts +1 -20
- package/dist/koa/index.d.mts +1 -20
- package/dist/koa/index.mjs +1 -1
- package/dist/{router-CAnd539U.cjs → router--8gWGXv-.cjs} +48 -2
- package/dist/{router-jwZwD8ZT.d.cts → router-Bu4kNHUo.d.cts} +90 -14
- package/dist/{router-DSq9dtuQ.mjs → router-DgZmT-17.mjs} +48 -2
- package/dist/{router-Bk8mXRu1.d.mts → router-awXi28kb.d.mts} +90 -14
- package/dist/types/ClearRequest.d.mts +6 -3
- package/dist/types/core/Response.d.mts +1 -0
- package/package.json +3 -2
package/dist/core/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_bindings = require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/core/plugins.ts
|
|
6
6
|
function definePlugin(plugin) {
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as Response, a as ClearRouterPluginInput, c as PluginBind, d as PluginSetupResult, f as definePlugin, i as ClearRouterPluginContext, l as PluginBindFactory, n as ClearRouterPlugin, o as ClearRouterPluginRequestContext, p as Request, r as ClearRouterPluginArgumentsContext, s as PluginArgumentsResolver, t as CoreRouter, u as PluginBindValue } from "../router-Bu4kNHUo.cjs";
|
|
2
2
|
export { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, definePlugin };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as Response, a as ClearRouterPluginInput, c as PluginBind, d as PluginSetupResult, f as definePlugin, i as ClearRouterPluginContext, l as PluginBindFactory, n as ClearRouterPlugin, o as ClearRouterPluginRequestContext, p as Request, r as ClearRouterPluginArgumentsContext, s as PluginArgumentsResolver, t as CoreRouter, u as PluginBindValue } from "../router-awXi28kb.mjs";
|
|
2
2
|
export { ClearRouterPlugin, ClearRouterPluginArgumentsContext, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, CoreRouter, PluginArgumentsResolver, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, definePlugin };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_bindings = require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
require('./index.cjs');
|
|
5
5
|
require("reflect-metadata");
|
|
6
6
|
|
package/dist/express/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
const require_responses = require('../responses-Bvnk0uvc.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/express/router.ts
|
package/dist/express/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as ControllerAction, I as HttpMethod, M as HttpContext, N as Middleware, P as ApiResourceMiddleware, j as Handler, m as Route, t as CoreRouter } from "../router-Bu4kNHUo.cjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
package/dist/express/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as ControllerAction, I as HttpMethod, M as HttpContext, N as Middleware, P as ApiResourceMiddleware, j as Handler, m as Route, t as CoreRouter } from "../router-awXi28kb.mjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
package/dist/express/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../bindings-XLDXFpHZ.mjs";
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
2
|
+
import { t as CoreRouter } from "../router-DgZmT-17.mjs";
|
|
3
3
|
import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-BvETUeDL.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/express/router.ts
|
package/dist/fastify/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
const require_responses = require('../responses-Bvnk0uvc.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/fastify/router.ts
|
package/dist/fastify/index.d.cts
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
1
|
+
import { A as Middleware, D as FastifyApp, F as ControllerAction, I as HttpMethod, O as Handler, P as ApiResourceMiddleware, k as HttpContext, m as Route, t as CoreRouter } from "../router-Bu4kNHUo.cjs";
|
|
3
2
|
|
|
4
|
-
//#region types/fastify.d.ts
|
|
5
|
-
interface RequestWithGetBody extends FastifyRequest {
|
|
6
|
-
getBody: () => Record<string, any>;
|
|
7
|
-
}
|
|
8
|
-
interface HttpContext {
|
|
9
|
-
req: RequestWithGetBody;
|
|
10
|
-
reply: FastifyReply;
|
|
11
|
-
clearRequest: Request;
|
|
12
|
-
clearResponse: Response;
|
|
13
|
-
}
|
|
14
|
-
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
15
|
-
type Handler = RouteHandler | ControllerHandler;
|
|
16
|
-
type NextFunction = (err?: Error) => void;
|
|
17
|
-
type Middleware = (req: RequestWithGetBody, reply: FastifyReply, next: NextFunction) => any | Promise<any>;
|
|
18
|
-
type FastifyApp = FastifyInstance;
|
|
19
|
-
//#endregion
|
|
20
3
|
//#region src/fastify/router.d.ts
|
|
21
4
|
/**
|
|
22
5
|
* @class clear-router Fastify Router
|
package/dist/fastify/index.d.mts
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
1
|
+
import { A as Middleware, D as FastifyApp, F as ControllerAction, I as HttpMethod, O as Handler, P as ApiResourceMiddleware, k as HttpContext, m as Route, t as CoreRouter } from "../router-awXi28kb.mjs";
|
|
3
2
|
|
|
4
|
-
//#region types/fastify.d.ts
|
|
5
|
-
interface RequestWithGetBody extends FastifyRequest {
|
|
6
|
-
getBody: () => Record<string, any>;
|
|
7
|
-
}
|
|
8
|
-
interface HttpContext {
|
|
9
|
-
req: RequestWithGetBody;
|
|
10
|
-
reply: FastifyReply;
|
|
11
|
-
clearRequest: Request;
|
|
12
|
-
clearResponse: Response;
|
|
13
|
-
}
|
|
14
|
-
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
15
|
-
type Handler = RouteHandler | ControllerHandler;
|
|
16
|
-
type NextFunction = (err?: Error) => void;
|
|
17
|
-
type Middleware = (req: RequestWithGetBody, reply: FastifyReply, next: NextFunction) => any | Promise<any>;
|
|
18
|
-
type FastifyApp = FastifyInstance;
|
|
19
|
-
//#endregion
|
|
20
3
|
//#region src/fastify/router.d.ts
|
|
21
4
|
/**
|
|
22
5
|
* @class clear-router Fastify Router
|
package/dist/fastify/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../bindings-XLDXFpHZ.mjs";
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
2
|
+
import { t as CoreRouter } from "../router-DgZmT-17.mjs";
|
|
3
3
|
import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-BvETUeDL.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/fastify/router.ts
|
package/dist/h3/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
const require_responses = require('../responses-Bvnk0uvc.cjs');
|
|
5
5
|
let h3 = require("h3");
|
|
6
6
|
|
package/dist/h3/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as H3App, E as Middleware, F as ControllerAction, I as HttpMethod, P as ApiResourceMiddleware, T as HttpContext, m as Route, t as CoreRouter, w as Handler } from "../router-Bu4kNHUo.cjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.d.ts
|
package/dist/h3/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as H3App, E as Middleware, F as ControllerAction, I as HttpMethod, P as ApiResourceMiddleware, T as HttpContext, m as Route, t as CoreRouter, w as Handler } from "../router-awXi28kb.mjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.d.ts
|
package/dist/h3/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../bindings-XLDXFpHZ.mjs";
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
2
|
+
import { t as CoreRouter } from "../router-DgZmT-17.mjs";
|
|
3
3
|
import { n as resolveResponseMeta } from "../responses-BvETUeDL.mjs";
|
|
4
4
|
import { HTTPResponse, getQuery, getRouterParams, readBody } from "h3";
|
|
5
5
|
|
package/dist/hono/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
const require_responses = require('../responses-Bvnk0uvc.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/hono/router.ts
|
package/dist/hono/index.d.cts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
1
|
+
import { F as ControllerAction, I as HttpMethod, P as ApiResourceMiddleware, S as Middleware, b as HonoApp, m as Route, t as CoreRouter, x as HttpContext, y as Handler } from "../router-Bu4kNHUo.cjs";
|
|
3
2
|
|
|
4
|
-
//#region types/hono.d.ts
|
|
5
|
-
type RequestWithGetBody = HonoRequest & {
|
|
6
|
-
getBody: () => Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
type HttpContext = Context & {
|
|
9
|
-
req: RequestWithGetBody;
|
|
10
|
-
clearRequest: Request;
|
|
11
|
-
clearResponse: Response;
|
|
12
|
-
};
|
|
13
|
-
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
14
|
-
type Handler = RouteHandler | ControllerHandler;
|
|
15
|
-
type Middleware = MiddlewareHandler;
|
|
16
|
-
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: Middleware[]) => any };
|
|
17
|
-
//#endregion
|
|
18
3
|
//#region src/hono/router.d.ts
|
|
19
4
|
/**
|
|
20
5
|
* @class clear-router Hono Router
|
package/dist/hono/index.d.mts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
1
|
+
import { F as ControllerAction, I as HttpMethod, P as ApiResourceMiddleware, S as Middleware, b as HonoApp, m as Route, t as CoreRouter, x as HttpContext, y as Handler } from "../router-awXi28kb.mjs";
|
|
3
2
|
|
|
4
|
-
//#region types/hono.d.ts
|
|
5
|
-
type RequestWithGetBody = HonoRequest & {
|
|
6
|
-
getBody: () => Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
type HttpContext = Context & {
|
|
9
|
-
req: RequestWithGetBody;
|
|
10
|
-
clearRequest: Request;
|
|
11
|
-
clearResponse: Response;
|
|
12
|
-
};
|
|
13
|
-
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
14
|
-
type Handler = RouteHandler | ControllerHandler;
|
|
15
|
-
type Middleware = MiddlewareHandler;
|
|
16
|
-
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: Middleware[]) => any };
|
|
17
|
-
//#endregion
|
|
18
3
|
//#region src/hono/router.d.ts
|
|
19
4
|
/**
|
|
20
5
|
* @class clear-router Hono Router
|
package/dist/hono/index.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -299,6 +299,21 @@ var CoreRouter = class {
|
|
|
299
299
|
static pluginStoreKey = Symbol.for("clear-router:plugins");
|
|
300
300
|
static pluginPendingKey = Symbol.for("clear-router:plugin-promises");
|
|
301
301
|
static pluginArgumentResolversKey = Symbol.for("clear-router:plugin-argument-resolvers");
|
|
302
|
+
static requestProvider;
|
|
303
|
+
static responseProvider;
|
|
304
|
+
/**
|
|
305
|
+
* Resets the router to it's default state
|
|
306
|
+
*/
|
|
307
|
+
static reset() {
|
|
308
|
+
this.routes = [];
|
|
309
|
+
this.prefix = "";
|
|
310
|
+
this.groupMiddlewares = [];
|
|
311
|
+
this.globalMiddlewares = [];
|
|
312
|
+
this.routesByPathMethod = {};
|
|
313
|
+
this.routesByMethod = {};
|
|
314
|
+
this.routesByName = {};
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
302
317
|
static createBaseConfig() {
|
|
303
318
|
return {
|
|
304
319
|
methodOverride: {
|
|
@@ -886,6 +901,37 @@ var CoreRouter = class {
|
|
|
886
901
|
static url(name, params) {
|
|
887
902
|
return this.route(name)?.toPath(params);
|
|
888
903
|
}
|
|
904
|
+
/**
|
|
905
|
+
* Provide a class that will overide the base Request instance
|
|
906
|
+
*
|
|
907
|
+
* @param provider
|
|
908
|
+
*/
|
|
909
|
+
static setRequestProvider(provider) {
|
|
910
|
+
this.requestProvider = provider;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Provide a class that will overide the base Response instance
|
|
914
|
+
*
|
|
915
|
+
* @param provider
|
|
916
|
+
*/
|
|
917
|
+
static setResponseProvider(provider) {
|
|
918
|
+
this.responseProvider = provider;
|
|
919
|
+
}
|
|
920
|
+
static initializeInstance(provider, args) {
|
|
921
|
+
const isRequest = [
|
|
922
|
+
"CoreRequest",
|
|
923
|
+
"Request",
|
|
924
|
+
"ClearRequest"
|
|
925
|
+
].includes(provider.name);
|
|
926
|
+
const isResponse = [
|
|
927
|
+
"CoreResponse",
|
|
928
|
+
"Response",
|
|
929
|
+
"ClearResponse"
|
|
930
|
+
].includes(provider.name);
|
|
931
|
+
if (isRequest && this.requestProvider) return new this.requestProvider(args);
|
|
932
|
+
else if (isResponse && this.responseProvider) return new this.responseProvider(args);
|
|
933
|
+
return new provider(args);
|
|
934
|
+
}
|
|
889
935
|
static resolveHandler(route) {
|
|
890
936
|
let handlerFunction;
|
|
891
937
|
let instance = null;
|
|
@@ -963,7 +1009,7 @@ var CoreRouter = class {
|
|
|
963
1009
|
});
|
|
964
1010
|
}
|
|
965
1011
|
static bindRequestToInstance(ctx, instance, route, payload) {
|
|
966
|
-
const clearRequest = ctx.clearRequest instanceof Request ? ctx.clearRequest :
|
|
1012
|
+
const clearRequest = ctx.clearRequest instanceof Request ? ctx.clearRequest : this.initializeInstance(Request, {
|
|
967
1013
|
ctx,
|
|
968
1014
|
route,
|
|
969
1015
|
body: payload.body,
|
|
@@ -983,7 +1029,7 @@ var CoreRouter = class {
|
|
|
983
1029
|
ctx.clearRequest = clearRequest;
|
|
984
1030
|
Container.bind(Request, ctx.clearRequest);
|
|
985
1031
|
if (!(ctx.clearResponse instanceof Response)) {
|
|
986
|
-
ctx.clearResponse =
|
|
1032
|
+
ctx.clearResponse = this.initializeInstance(Response, ctx.response ?? ctx.reply ?? ctx.res);
|
|
987
1033
|
Container.bind(Response, ctx.clearResponse);
|
|
988
1034
|
}
|
|
989
1035
|
if (!instance) return;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { NextFunction, Request as Request$1, Response as Response$2 } from "express";
|
|
2
|
-
import { Middleware as Middleware$
|
|
2
|
+
import { Middleware as Middleware$4 } from "h3";
|
|
3
|
+
import { FastifyReply, FastifyRequest } from "fastify";
|
|
4
|
+
import { MiddlewareHandler } from "hono";
|
|
5
|
+
import Koa from "koa";
|
|
3
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
7
|
|
|
5
8
|
//#region types/basic.d.ts
|
|
@@ -37,6 +40,7 @@ interface RouterConfig {
|
|
|
37
40
|
//#endregion
|
|
38
41
|
//#region src/core/Response.d.ts
|
|
39
42
|
declare class Response$1 {
|
|
43
|
+
[key: string]: any;
|
|
40
44
|
body: any;
|
|
41
45
|
headers: Headers;
|
|
42
46
|
sent: boolean;
|
|
@@ -63,7 +67,7 @@ interface RouteParameter {
|
|
|
63
67
|
field?: string;
|
|
64
68
|
optional: boolean;
|
|
65
69
|
}
|
|
66
|
-
declare class Route<X = any, M = Middleware$
|
|
70
|
+
declare class Route<X = any, M = Middleware$4 | Middleware$3, H = any> {
|
|
67
71
|
ctx: X;
|
|
68
72
|
body: RequestData;
|
|
69
73
|
query: RequestData;
|
|
@@ -114,10 +118,23 @@ declare class Request<X = any, M = any> extends ClearRequest<X, M> {
|
|
|
114
118
|
/**
|
|
115
119
|
* Middleware function type
|
|
116
120
|
*/
|
|
117
|
-
type Middleware = (req: Request$1, res: Response$2, next: NextFunction) => any | Promise<any>;
|
|
121
|
+
type Middleware$3 = (req: Request$1, res: Response$2, next: NextFunction) => any | Promise<any>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region types/fastify.d.ts
|
|
124
|
+
interface RequestWithGetBody extends FastifyRequest {
|
|
125
|
+
getBody: () => Record<string, any>;
|
|
126
|
+
}
|
|
127
|
+
type NextFunction$1 = (err?: Error) => void;
|
|
128
|
+
type Middleware$2 = (req: RequestWithGetBody, reply: FastifyReply, next: NextFunction$1) => any | Promise<any>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region types/hono.d.ts
|
|
131
|
+
type Middleware$1 = MiddlewareHandler;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region types/koa.d.ts
|
|
134
|
+
type Middleware = Koa.Middleware<any, any>;
|
|
118
135
|
//#endregion
|
|
119
136
|
//#region src/ClearRequest.d.ts
|
|
120
|
-
declare class ClearRequest<X = any, M = Middleware$1 | Middleware> {
|
|
137
|
+
declare class ClearRequest<X = any, M = Middleware$4 | Middleware$3 | Middleware$2 | Middleware$1 | Middleware> {
|
|
121
138
|
[key: string]: any;
|
|
122
139
|
/**
|
|
123
140
|
* @param body - Parsed request body
|
|
@@ -220,6 +237,12 @@ declare abstract class CoreRouter {
|
|
|
220
237
|
private static readonly pluginStoreKey;
|
|
221
238
|
private static readonly pluginPendingKey;
|
|
222
239
|
private static readonly pluginArgumentResolversKey;
|
|
240
|
+
private static requestProvider?;
|
|
241
|
+
private static responseProvider?;
|
|
242
|
+
/**
|
|
243
|
+
* Resets the router to it's default state
|
|
244
|
+
*/
|
|
245
|
+
static reset(): typeof CoreRouter;
|
|
223
246
|
protected static createBaseConfig(): RouterConfig;
|
|
224
247
|
protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
|
|
225
248
|
protected static getDefaultConfig(): RouterConfig;
|
|
@@ -420,6 +443,24 @@ declare abstract class CoreRouter {
|
|
|
420
443
|
static allRoutes(type: 'name'): Record<string, Route<any, any, any>>;
|
|
421
444
|
static route(name: string): Route<any, any, any> | undefined;
|
|
422
445
|
static url(name: string, params?: Record<string, any>): string | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* Provide a class that will overide the base Request instance
|
|
448
|
+
*
|
|
449
|
+
* @param provider
|
|
450
|
+
*/
|
|
451
|
+
static setRequestProvider(provider: typeof Request): void;
|
|
452
|
+
/**
|
|
453
|
+
* Provide a class that will overide the base Response instance
|
|
454
|
+
*
|
|
455
|
+
* @param provider
|
|
456
|
+
*/
|
|
457
|
+
static setResponseProvider(provider: typeof Response$1): void;
|
|
458
|
+
/**
|
|
459
|
+
* Provide a class that will overide the base Response instance
|
|
460
|
+
*
|
|
461
|
+
* @param provider
|
|
462
|
+
*/
|
|
463
|
+
private static initializeInstance;
|
|
423
464
|
protected static resolveHandler(route: Route<any, any, any>): {
|
|
424
465
|
handlerFunction: ((ctx: any, req: Request) => any | Promise<any>) | null;
|
|
425
466
|
instance: Controller<any> | null;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { NextFunction, Request as Request$1, Response as Response$2 } from "express";
|
|
3
|
-
import { Middleware as Middleware$
|
|
3
|
+
import { Middleware as Middleware$4 } from "h3";
|
|
4
|
+
import { FastifyReply, FastifyRequest } from "fastify";
|
|
5
|
+
import { MiddlewareHandler } from "hono";
|
|
6
|
+
import Koa from "koa";
|
|
4
7
|
|
|
5
8
|
//#region types/basic.d.ts
|
|
6
9
|
/**
|
|
@@ -37,6 +40,7 @@ interface RouterConfig {
|
|
|
37
40
|
//#endregion
|
|
38
41
|
//#region src/core/Response.d.ts
|
|
39
42
|
declare class Response$1 {
|
|
43
|
+
[key: string]: any;
|
|
40
44
|
body: any;
|
|
41
45
|
headers: Headers;
|
|
42
46
|
sent: boolean;
|
|
@@ -63,7 +67,7 @@ interface RouteParameter {
|
|
|
63
67
|
field?: string;
|
|
64
68
|
optional: boolean;
|
|
65
69
|
}
|
|
66
|
-
declare class Route<X = any, M = Middleware$
|
|
70
|
+
declare class Route<X = any, M = Middleware$4 | Middleware$3, H = any> {
|
|
67
71
|
ctx: X;
|
|
68
72
|
body: RequestData;
|
|
69
73
|
query: RequestData;
|
|
@@ -114,10 +118,23 @@ declare class Request<X = any, M = any> extends ClearRequest<X, M> {
|
|
|
114
118
|
/**
|
|
115
119
|
* Middleware function type
|
|
116
120
|
*/
|
|
117
|
-
type Middleware = (req: Request$1, res: Response$2, next: NextFunction) => any | Promise<any>;
|
|
121
|
+
type Middleware$3 = (req: Request$1, res: Response$2, next: NextFunction) => any | Promise<any>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region types/fastify.d.ts
|
|
124
|
+
interface RequestWithGetBody extends FastifyRequest {
|
|
125
|
+
getBody: () => Record<string, any>;
|
|
126
|
+
}
|
|
127
|
+
type NextFunction$1 = (err?: Error) => void;
|
|
128
|
+
type Middleware$2 = (req: RequestWithGetBody, reply: FastifyReply, next: NextFunction$1) => any | Promise<any>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region types/hono.d.ts
|
|
131
|
+
type Middleware$1 = MiddlewareHandler;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region types/koa.d.ts
|
|
134
|
+
type Middleware = Koa.Middleware<any, any>;
|
|
118
135
|
//#endregion
|
|
119
136
|
//#region src/ClearRequest.d.ts
|
|
120
|
-
declare class ClearRequest<X = any, M = Middleware$1 | Middleware> {
|
|
137
|
+
declare class ClearRequest<X = any, M = Middleware$4 | Middleware$3 | Middleware$2 | Middleware$1 | Middleware> {
|
|
121
138
|
[key: string]: any;
|
|
122
139
|
/**
|
|
123
140
|
* @param body - Parsed request body
|
|
@@ -220,6 +237,12 @@ declare abstract class CoreRouter {
|
|
|
220
237
|
private static readonly pluginStoreKey;
|
|
221
238
|
private static readonly pluginPendingKey;
|
|
222
239
|
private static readonly pluginArgumentResolversKey;
|
|
240
|
+
private static requestProvider?;
|
|
241
|
+
private static responseProvider?;
|
|
242
|
+
/**
|
|
243
|
+
* Resets the router to it's default state
|
|
244
|
+
*/
|
|
245
|
+
static reset(): typeof CoreRouter;
|
|
223
246
|
protected static createBaseConfig(): RouterConfig;
|
|
224
247
|
protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
|
|
225
248
|
protected static getDefaultConfig(): RouterConfig;
|
|
@@ -420,6 +443,24 @@ declare abstract class CoreRouter {
|
|
|
420
443
|
static allRoutes(type: 'name'): Record<string, Route<any, any, any>>;
|
|
421
444
|
static route(name: string): Route<any, any, any> | undefined;
|
|
422
445
|
static url(name: string, params?: Record<string, any>): string | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* Provide a class that will overide the base Request instance
|
|
448
|
+
*
|
|
449
|
+
* @param provider
|
|
450
|
+
*/
|
|
451
|
+
static setRequestProvider(provider: typeof Request): void;
|
|
452
|
+
/**
|
|
453
|
+
* Provide a class that will overide the base Response instance
|
|
454
|
+
*
|
|
455
|
+
* @param provider
|
|
456
|
+
*/
|
|
457
|
+
static setResponseProvider(provider: typeof Response$1): void;
|
|
458
|
+
/**
|
|
459
|
+
* Provide a class that will overide the base Response instance
|
|
460
|
+
*
|
|
461
|
+
* @param provider
|
|
462
|
+
*/
|
|
463
|
+
private static initializeInstance;
|
|
423
464
|
protected static resolveHandler(route: Route<any, any, any>): {
|
|
424
465
|
handlerFunction: ((ctx: any, req: Request) => any | Promise<any>) | null;
|
|
425
466
|
instance: Controller<any> | null;
|
package/dist/index.mjs
CHANGED
|
@@ -298,6 +298,21 @@ var CoreRouter = class {
|
|
|
298
298
|
static pluginStoreKey = Symbol.for("clear-router:plugins");
|
|
299
299
|
static pluginPendingKey = Symbol.for("clear-router:plugin-promises");
|
|
300
300
|
static pluginArgumentResolversKey = Symbol.for("clear-router:plugin-argument-resolvers");
|
|
301
|
+
static requestProvider;
|
|
302
|
+
static responseProvider;
|
|
303
|
+
/**
|
|
304
|
+
* Resets the router to it's default state
|
|
305
|
+
*/
|
|
306
|
+
static reset() {
|
|
307
|
+
this.routes = [];
|
|
308
|
+
this.prefix = "";
|
|
309
|
+
this.groupMiddlewares = [];
|
|
310
|
+
this.globalMiddlewares = [];
|
|
311
|
+
this.routesByPathMethod = {};
|
|
312
|
+
this.routesByMethod = {};
|
|
313
|
+
this.routesByName = {};
|
|
314
|
+
return this;
|
|
315
|
+
}
|
|
301
316
|
static createBaseConfig() {
|
|
302
317
|
return {
|
|
303
318
|
methodOverride: {
|
|
@@ -885,6 +900,37 @@ var CoreRouter = class {
|
|
|
885
900
|
static url(name, params) {
|
|
886
901
|
return this.route(name)?.toPath(params);
|
|
887
902
|
}
|
|
903
|
+
/**
|
|
904
|
+
* Provide a class that will overide the base Request instance
|
|
905
|
+
*
|
|
906
|
+
* @param provider
|
|
907
|
+
*/
|
|
908
|
+
static setRequestProvider(provider) {
|
|
909
|
+
this.requestProvider = provider;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Provide a class that will overide the base Response instance
|
|
913
|
+
*
|
|
914
|
+
* @param provider
|
|
915
|
+
*/
|
|
916
|
+
static setResponseProvider(provider) {
|
|
917
|
+
this.responseProvider = provider;
|
|
918
|
+
}
|
|
919
|
+
static initializeInstance(provider, args) {
|
|
920
|
+
const isRequest = [
|
|
921
|
+
"CoreRequest",
|
|
922
|
+
"Request",
|
|
923
|
+
"ClearRequest"
|
|
924
|
+
].includes(provider.name);
|
|
925
|
+
const isResponse = [
|
|
926
|
+
"CoreResponse",
|
|
927
|
+
"Response",
|
|
928
|
+
"ClearResponse"
|
|
929
|
+
].includes(provider.name);
|
|
930
|
+
if (isRequest && this.requestProvider) return new this.requestProvider(args);
|
|
931
|
+
else if (isResponse && this.responseProvider) return new this.responseProvider(args);
|
|
932
|
+
return new provider(args);
|
|
933
|
+
}
|
|
888
934
|
static resolveHandler(route) {
|
|
889
935
|
let handlerFunction;
|
|
890
936
|
let instance = null;
|
|
@@ -962,7 +1008,7 @@ var CoreRouter = class {
|
|
|
962
1008
|
});
|
|
963
1009
|
}
|
|
964
1010
|
static bindRequestToInstance(ctx, instance, route, payload) {
|
|
965
|
-
const clearRequest = ctx.clearRequest instanceof Request ? ctx.clearRequest :
|
|
1011
|
+
const clearRequest = ctx.clearRequest instanceof Request ? ctx.clearRequest : this.initializeInstance(Request, {
|
|
966
1012
|
ctx,
|
|
967
1013
|
route,
|
|
968
1014
|
body: payload.body,
|
|
@@ -982,7 +1028,7 @@ var CoreRouter = class {
|
|
|
982
1028
|
ctx.clearRequest = clearRequest;
|
|
983
1029
|
Container.bind(Request, ctx.clearRequest);
|
|
984
1030
|
if (!(ctx.clearResponse instanceof Response)) {
|
|
985
|
-
ctx.clearResponse =
|
|
1031
|
+
ctx.clearResponse = this.initializeInstance(Response, ctx.response ?? ctx.reply ?? ctx.res);
|
|
986
1032
|
Container.bind(Response, ctx.clearResponse);
|
|
987
1033
|
}
|
|
988
1034
|
if (!instance) return;
|
package/dist/koa/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
require('../bindings-CLsZjOEy.cjs');
|
|
3
|
-
const require_router = require('../router
|
|
3
|
+
const require_router = require('../router--8gWGXv-.cjs');
|
|
4
4
|
const require_responses = require('../responses-Bvnk0uvc.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/koa/router.ts
|
package/dist/koa/index.d.cts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Koa from "koa";
|
|
3
|
-
import Router$1 from "@koa/router";
|
|
1
|
+
import { F as ControllerAction, I as HttpMethod, P as ApiResourceMiddleware, _ as KoaRouterApp, g as HttpContext, h as Handler, m as Route, t as CoreRouter, v as Middleware } from "../router-Bu4kNHUo.cjs";
|
|
4
2
|
|
|
5
|
-
//#region types/koa.d.ts
|
|
6
|
-
interface RequestWithGetBody extends Koa.Request {
|
|
7
|
-
getBody: () => Record<string, any>;
|
|
8
|
-
body?: any;
|
|
9
|
-
}
|
|
10
|
-
interface HttpContext extends Koa.Context {
|
|
11
|
-
request: RequestWithGetBody;
|
|
12
|
-
clearRequest: Request;
|
|
13
|
-
clearResponse: Response;
|
|
14
|
-
params: Record<string, any>;
|
|
15
|
-
query: Record<string, any>;
|
|
16
|
-
}
|
|
17
|
-
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
18
|
-
type Handler = RouteHandler | ControllerHandler;
|
|
19
|
-
type Middleware = Koa.Middleware<any, any>;
|
|
20
|
-
type KoaRouterApp = Router$1<any, any>;
|
|
21
|
-
//#endregion
|
|
22
3
|
//#region src/koa/router.d.ts
|
|
23
4
|
/**
|
|
24
5
|
* @class clear-router Koa Router
|
package/dist/koa/index.d.mts
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Koa from "koa";
|
|
3
|
-
import Router$1 from "@koa/router";
|
|
1
|
+
import { F as ControllerAction, I as HttpMethod, P as ApiResourceMiddleware, _ as KoaRouterApp, g as HttpContext, h as Handler, m as Route, t as CoreRouter, v as Middleware } from "../router-awXi28kb.mjs";
|
|
4
2
|
|
|
5
|
-
//#region types/koa.d.ts
|
|
6
|
-
interface RequestWithGetBody extends Koa.Request {
|
|
7
|
-
getBody: () => Record<string, any>;
|
|
8
|
-
body?: any;
|
|
9
|
-
}
|
|
10
|
-
interface HttpContext extends Koa.Context {
|
|
11
|
-
request: RequestWithGetBody;
|
|
12
|
-
clearRequest: Request;
|
|
13
|
-
clearResponse: Response;
|
|
14
|
-
params: Record<string, any>;
|
|
15
|
-
query: Record<string, any>;
|
|
16
|
-
}
|
|
17
|
-
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
18
|
-
type Handler = RouteHandler | ControllerHandler;
|
|
19
|
-
type Middleware = Koa.Middleware<any, any>;
|
|
20
|
-
type KoaRouterApp = Router$1<any, any>;
|
|
21
|
-
//#endregion
|
|
22
3
|
//#region src/koa/router.d.ts
|
|
23
4
|
/**
|
|
24
5
|
* @class clear-router Koa Router
|
package/dist/koa/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../bindings-XLDXFpHZ.mjs";
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
2
|
+
import { t as CoreRouter } from "../router-DgZmT-17.mjs";
|
|
3
3
|
import { n as resolveResponseMeta, t as isFetchResponse } from "../responses-BvETUeDL.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/koa/router.ts
|
|
@@ -72,6 +72,21 @@ var CoreRouter = class {
|
|
|
72
72
|
static pluginStoreKey = Symbol.for("clear-router:plugins");
|
|
73
73
|
static pluginPendingKey = Symbol.for("clear-router:plugin-promises");
|
|
74
74
|
static pluginArgumentResolversKey = Symbol.for("clear-router:plugin-argument-resolvers");
|
|
75
|
+
static requestProvider;
|
|
76
|
+
static responseProvider;
|
|
77
|
+
/**
|
|
78
|
+
* Resets the router to it's default state
|
|
79
|
+
*/
|
|
80
|
+
static reset() {
|
|
81
|
+
this.routes = [];
|
|
82
|
+
this.prefix = "";
|
|
83
|
+
this.groupMiddlewares = [];
|
|
84
|
+
this.globalMiddlewares = [];
|
|
85
|
+
this.routesByPathMethod = {};
|
|
86
|
+
this.routesByMethod = {};
|
|
87
|
+
this.routesByName = {};
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
75
90
|
static createBaseConfig() {
|
|
76
91
|
return {
|
|
77
92
|
methodOverride: {
|
|
@@ -659,6 +674,37 @@ var CoreRouter = class {
|
|
|
659
674
|
static url(name, params) {
|
|
660
675
|
return this.route(name)?.toPath(params);
|
|
661
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* Provide a class that will overide the base Request instance
|
|
679
|
+
*
|
|
680
|
+
* @param provider
|
|
681
|
+
*/
|
|
682
|
+
static setRequestProvider(provider) {
|
|
683
|
+
this.requestProvider = provider;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Provide a class that will overide the base Response instance
|
|
687
|
+
*
|
|
688
|
+
* @param provider
|
|
689
|
+
*/
|
|
690
|
+
static setResponseProvider(provider) {
|
|
691
|
+
this.responseProvider = provider;
|
|
692
|
+
}
|
|
693
|
+
static initializeInstance(provider, args) {
|
|
694
|
+
const isRequest = [
|
|
695
|
+
"CoreRequest",
|
|
696
|
+
"Request",
|
|
697
|
+
"ClearRequest"
|
|
698
|
+
].includes(provider.name);
|
|
699
|
+
const isResponse = [
|
|
700
|
+
"CoreResponse",
|
|
701
|
+
"Response",
|
|
702
|
+
"ClearResponse"
|
|
703
|
+
].includes(provider.name);
|
|
704
|
+
if (isRequest && this.requestProvider) return new this.requestProvider(args);
|
|
705
|
+
else if (isResponse && this.responseProvider) return new this.responseProvider(args);
|
|
706
|
+
return new provider(args);
|
|
707
|
+
}
|
|
662
708
|
static resolveHandler(route) {
|
|
663
709
|
let handlerFunction;
|
|
664
710
|
let instance = null;
|
|
@@ -736,7 +782,7 @@ var CoreRouter = class {
|
|
|
736
782
|
});
|
|
737
783
|
}
|
|
738
784
|
static bindRequestToInstance(ctx, instance, route, payload) {
|
|
739
|
-
const clearRequest = ctx.clearRequest instanceof require_bindings.Request ? ctx.clearRequest :
|
|
785
|
+
const clearRequest = ctx.clearRequest instanceof require_bindings.Request ? ctx.clearRequest : this.initializeInstance(require_bindings.Request, {
|
|
740
786
|
ctx,
|
|
741
787
|
route,
|
|
742
788
|
body: payload.body,
|
|
@@ -756,7 +802,7 @@ var CoreRouter = class {
|
|
|
756
802
|
ctx.clearRequest = clearRequest;
|
|
757
803
|
require_bindings.Container.bind(require_bindings.Request, ctx.clearRequest);
|
|
758
804
|
if (!(ctx.clearResponse instanceof require_bindings.Response)) {
|
|
759
|
-
ctx.clearResponse =
|
|
805
|
+
ctx.clearResponse = this.initializeInstance(require_bindings.Response, ctx.response ?? ctx.reply ?? ctx.res);
|
|
760
806
|
require_bindings.Container.bind(require_bindings.Response, ctx.clearResponse);
|
|
761
807
|
}
|
|
762
808
|
if (!instance) return;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { a as BindValue, i as BindToken, o as Container } from "./bindings-CxvtC8XS.cjs";
|
|
2
2
|
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
3
|
-
import {
|
|
3
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
4
|
+
import { EventHandlerRequest, H3, H3Event, Middleware as Middleware$2, TypedServerRequest } from "h3";
|
|
5
|
+
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
6
|
+
import Koa from "koa";
|
|
7
|
+
import Router$1 from "@koa/router";
|
|
4
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
9
|
|
|
6
10
|
//#region src/core/Response.d.ts
|
|
7
11
|
declare class Response$2 {
|
|
12
|
+
[key: string]: any;
|
|
8
13
|
body: any;
|
|
9
14
|
headers: Headers;
|
|
10
15
|
sent: boolean;
|
|
@@ -63,14 +68,14 @@ interface RouterConfig {
|
|
|
63
68
|
}
|
|
64
69
|
//#endregion
|
|
65
70
|
//#region types/express.d.ts
|
|
66
|
-
interface RequestWithGetBody extends Request {
|
|
71
|
+
interface RequestWithGetBody$3 extends Request {
|
|
67
72
|
getBody: () => Record<string, any>;
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* HTTP context passed to route handlers
|
|
71
76
|
*/
|
|
72
|
-
interface HttpContext$
|
|
73
|
-
req: RequestWithGetBody;
|
|
77
|
+
interface HttpContext$4 {
|
|
78
|
+
req: RequestWithGetBody$3;
|
|
74
79
|
res: Response$1;
|
|
75
80
|
next: NextFunction;
|
|
76
81
|
clearRequest: Request$1;
|
|
@@ -79,12 +84,12 @@ interface HttpContext$1 {
|
|
|
79
84
|
/**
|
|
80
85
|
* Route handler function type
|
|
81
86
|
*/
|
|
82
|
-
type RouteHandler$
|
|
87
|
+
type RouteHandler$4 = (
|
|
83
88
|
/**
|
|
84
89
|
* Express context object containing req, res, and next
|
|
85
90
|
*/
|
|
86
91
|
|
|
87
|
-
ctx: HttpContext$
|
|
92
|
+
ctx: HttpContext$4,
|
|
88
93
|
/**
|
|
89
94
|
* ClearRequest instance
|
|
90
95
|
*/
|
|
@@ -93,11 +98,27 @@ req: Request$1) => any | Promise<any>;
|
|
|
93
98
|
/**
|
|
94
99
|
* Handler can be either a function or controller reference
|
|
95
100
|
*/
|
|
96
|
-
type Handler$
|
|
101
|
+
type Handler$4 = RouteHandler$4 | ControllerHandler;
|
|
97
102
|
/**
|
|
98
103
|
* Middleware function type
|
|
99
104
|
*/
|
|
100
|
-
type Middleware$
|
|
105
|
+
type Middleware$4 = (req: Request, res: Response$1, next: NextFunction) => any | Promise<any>;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region types/fastify.d.ts
|
|
108
|
+
interface RequestWithGetBody$2 extends FastifyRequest {
|
|
109
|
+
getBody: () => Record<string, any>;
|
|
110
|
+
}
|
|
111
|
+
interface HttpContext$3 {
|
|
112
|
+
req: RequestWithGetBody$2;
|
|
113
|
+
reply: FastifyReply;
|
|
114
|
+
clearRequest: Request$1;
|
|
115
|
+
clearResponse: Response$2;
|
|
116
|
+
}
|
|
117
|
+
type RouteHandler$3 = (ctx: HttpContext$3, req: Request$1) => any | Promise<any>;
|
|
118
|
+
type Handler$3 = RouteHandler$3 | ControllerHandler;
|
|
119
|
+
type NextFunction$1 = (err?: Error) => void;
|
|
120
|
+
type Middleware$3 = (req: RequestWithGetBody$2, reply: FastifyReply, next: NextFunction$1) => any | Promise<any>;
|
|
121
|
+
type FastifyApp = FastifyInstance;
|
|
101
122
|
//#endregion
|
|
102
123
|
//#region types/h3.d.ts
|
|
103
124
|
type H3App = Omit<H3, 'fetch'> & {
|
|
@@ -110,7 +131,7 @@ type RequestlessH3Event = Omit<H3Event, 'req'>;
|
|
|
110
131
|
/**
|
|
111
132
|
* HTTP context passed to route handlers
|
|
112
133
|
*/
|
|
113
|
-
interface HttpContext extends RequestlessH3Event {
|
|
134
|
+
interface HttpContext$2 extends RequestlessH3Event {
|
|
114
135
|
req: HttpRequest;
|
|
115
136
|
clearRequest: Request$1;
|
|
116
137
|
clearResponse: Response$2;
|
|
@@ -118,12 +139,12 @@ interface HttpContext extends RequestlessH3Event {
|
|
|
118
139
|
/**
|
|
119
140
|
* Route handler function type
|
|
120
141
|
*/
|
|
121
|
-
type RouteHandler = (
|
|
142
|
+
type RouteHandler$2 = (
|
|
122
143
|
/**
|
|
123
144
|
* H3 event context
|
|
124
145
|
*/
|
|
125
146
|
|
|
126
|
-
ctx: HttpContext,
|
|
147
|
+
ctx: HttpContext$2,
|
|
127
148
|
/**
|
|
128
149
|
* ClearRequest instance
|
|
129
150
|
*/
|
|
@@ -132,7 +153,38 @@ req: Request$1) => any | Promise<any>;
|
|
|
132
153
|
/**
|
|
133
154
|
* Handler can be either a function or controller reference
|
|
134
155
|
*/
|
|
156
|
+
type Handler$2 = RouteHandler$2 | ControllerHandler;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region types/hono.d.ts
|
|
159
|
+
type RequestWithGetBody$1 = HonoRequest & {
|
|
160
|
+
getBody: () => Record<string, any>;
|
|
161
|
+
};
|
|
162
|
+
type HttpContext$1 = Context & {
|
|
163
|
+
req: RequestWithGetBody$1;
|
|
164
|
+
clearRequest: Request$1;
|
|
165
|
+
clearResponse: Response$2;
|
|
166
|
+
};
|
|
167
|
+
type RouteHandler$1 = (ctx: HttpContext$1, req: Request$1) => any | Promise<any>;
|
|
168
|
+
type Handler$1 = RouteHandler$1 | ControllerHandler;
|
|
169
|
+
type Middleware$1 = MiddlewareHandler;
|
|
170
|
+
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: Middleware$1[]) => any };
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region types/koa.d.ts
|
|
173
|
+
interface RequestWithGetBody extends Koa.Request {
|
|
174
|
+
getBody: () => Record<string, any>;
|
|
175
|
+
body?: any;
|
|
176
|
+
}
|
|
177
|
+
interface HttpContext extends Koa.Context {
|
|
178
|
+
request: RequestWithGetBody;
|
|
179
|
+
clearRequest: Request$1;
|
|
180
|
+
clearResponse: Response$2;
|
|
181
|
+
params: Record<string, any>;
|
|
182
|
+
query: Record<string, any>;
|
|
183
|
+
}
|
|
184
|
+
type RouteHandler = (ctx: HttpContext, req: Request$1) => any | Promise<any>;
|
|
135
185
|
type Handler = RouteHandler | ControllerHandler;
|
|
186
|
+
type Middleware = Koa.Middleware<any, any>;
|
|
187
|
+
type KoaRouterApp = Router$1<any, any>;
|
|
136
188
|
//#endregion
|
|
137
189
|
//#region src/Route.d.ts
|
|
138
190
|
interface RouteParameter {
|
|
@@ -140,7 +192,7 @@ interface RouteParameter {
|
|
|
140
192
|
field?: string;
|
|
141
193
|
optional: boolean;
|
|
142
194
|
}
|
|
143
|
-
declare class Route<X = any, M = Middleware | Middleware$
|
|
195
|
+
declare class Route<X = any, M = Middleware$2 | Middleware$4, H = any> {
|
|
144
196
|
ctx: X;
|
|
145
197
|
body: RequestData;
|
|
146
198
|
query: RequestData;
|
|
@@ -168,7 +220,7 @@ declare class Route<X = any, M = Middleware | Middleware$1, H = any> {
|
|
|
168
220
|
}
|
|
169
221
|
//#endregion
|
|
170
222
|
//#region src/ClearRequest.d.ts
|
|
171
|
-
declare class ClearRequest<X = any, M = Middleware | Middleware$1> {
|
|
223
|
+
declare class ClearRequest<X = any, M = Middleware$2 | Middleware$4 | Middleware$3 | Middleware$1 | Middleware> {
|
|
172
224
|
[key: string]: any;
|
|
173
225
|
/**
|
|
174
226
|
* @param body - Parsed request body
|
|
@@ -272,6 +324,12 @@ declare abstract class CoreRouter {
|
|
|
272
324
|
private static readonly pluginStoreKey;
|
|
273
325
|
private static readonly pluginPendingKey;
|
|
274
326
|
private static readonly pluginArgumentResolversKey;
|
|
327
|
+
private static requestProvider?;
|
|
328
|
+
private static responseProvider?;
|
|
329
|
+
/**
|
|
330
|
+
* Resets the router to it's default state
|
|
331
|
+
*/
|
|
332
|
+
static reset(): typeof CoreRouter;
|
|
275
333
|
protected static createBaseConfig(): RouterConfig;
|
|
276
334
|
protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
|
|
277
335
|
protected static getDefaultConfig(): RouterConfig;
|
|
@@ -472,6 +530,24 @@ declare abstract class CoreRouter {
|
|
|
472
530
|
static allRoutes(type: 'name'): Record<string, Route<any, any, any>>;
|
|
473
531
|
static route(name: string): Route<any, any, any> | undefined;
|
|
474
532
|
static url(name: string, params?: Record<string, any>): string | undefined;
|
|
533
|
+
/**
|
|
534
|
+
* Provide a class that will overide the base Request instance
|
|
535
|
+
*
|
|
536
|
+
* @param provider
|
|
537
|
+
*/
|
|
538
|
+
static setRequestProvider(provider: typeof Request$1): void;
|
|
539
|
+
/**
|
|
540
|
+
* Provide a class that will overide the base Response instance
|
|
541
|
+
*
|
|
542
|
+
* @param provider
|
|
543
|
+
*/
|
|
544
|
+
static setResponseProvider(provider: typeof Response$2): void;
|
|
545
|
+
/**
|
|
546
|
+
* Provide a class that will overide the base Response instance
|
|
547
|
+
*
|
|
548
|
+
* @param provider
|
|
549
|
+
*/
|
|
550
|
+
private static initializeInstance;
|
|
475
551
|
protected static resolveHandler(route: Route<any, any, any>): {
|
|
476
552
|
handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
|
|
477
553
|
instance: Controller<any> | null;
|
|
@@ -489,4 +565,4 @@ declare abstract class CoreRouter {
|
|
|
489
565
|
}): void;
|
|
490
566
|
}
|
|
491
567
|
//#endregion
|
|
492
|
-
export {
|
|
568
|
+
export { Middleware$3 as A, H3App as C, FastifyApp as D, Middleware$2 as E, ControllerAction as F, HttpMethod as I, Response$2 as L, HttpContext$4 as M, Middleware$4 as N, Handler$3 as O, ApiResourceMiddleware as P, Middleware$1 as S, HttpContext$2 as T, KoaRouterApp as _, ClearRouterPluginInput as a, HonoApp as b, PluginBind as c, PluginSetupResult as d, definePlugin as f, HttpContext as g, Handler as h, ClearRouterPluginContext as i, Handler$4 as j, HttpContext$3 as k, PluginBindFactory as l, Route as m, ClearRouterPlugin as n, ClearRouterPluginRequestContext as o, Request$1 as p, ClearRouterPluginArgumentsContext as r, PluginArgumentsResolver as s, CoreRouter as t, PluginBindValue as u, Middleware as v, Handler$2 as w, HttpContext$1 as x, Handler$1 as y };
|
|
@@ -72,6 +72,21 @@ var CoreRouter = class {
|
|
|
72
72
|
static pluginStoreKey = Symbol.for("clear-router:plugins");
|
|
73
73
|
static pluginPendingKey = Symbol.for("clear-router:plugin-promises");
|
|
74
74
|
static pluginArgumentResolversKey = Symbol.for("clear-router:plugin-argument-resolvers");
|
|
75
|
+
static requestProvider;
|
|
76
|
+
static responseProvider;
|
|
77
|
+
/**
|
|
78
|
+
* Resets the router to it's default state
|
|
79
|
+
*/
|
|
80
|
+
static reset() {
|
|
81
|
+
this.routes = [];
|
|
82
|
+
this.prefix = "";
|
|
83
|
+
this.groupMiddlewares = [];
|
|
84
|
+
this.globalMiddlewares = [];
|
|
85
|
+
this.routesByPathMethod = {};
|
|
86
|
+
this.routesByMethod = {};
|
|
87
|
+
this.routesByName = {};
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
75
90
|
static createBaseConfig() {
|
|
76
91
|
return {
|
|
77
92
|
methodOverride: {
|
|
@@ -659,6 +674,37 @@ var CoreRouter = class {
|
|
|
659
674
|
static url(name, params) {
|
|
660
675
|
return this.route(name)?.toPath(params);
|
|
661
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* Provide a class that will overide the base Request instance
|
|
679
|
+
*
|
|
680
|
+
* @param provider
|
|
681
|
+
*/
|
|
682
|
+
static setRequestProvider(provider) {
|
|
683
|
+
this.requestProvider = provider;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Provide a class that will overide the base Response instance
|
|
687
|
+
*
|
|
688
|
+
* @param provider
|
|
689
|
+
*/
|
|
690
|
+
static setResponseProvider(provider) {
|
|
691
|
+
this.responseProvider = provider;
|
|
692
|
+
}
|
|
693
|
+
static initializeInstance(provider, args) {
|
|
694
|
+
const isRequest = [
|
|
695
|
+
"CoreRequest",
|
|
696
|
+
"Request",
|
|
697
|
+
"ClearRequest"
|
|
698
|
+
].includes(provider.name);
|
|
699
|
+
const isResponse = [
|
|
700
|
+
"CoreResponse",
|
|
701
|
+
"Response",
|
|
702
|
+
"ClearResponse"
|
|
703
|
+
].includes(provider.name);
|
|
704
|
+
if (isRequest && this.requestProvider) return new this.requestProvider(args);
|
|
705
|
+
else if (isResponse && this.responseProvider) return new this.responseProvider(args);
|
|
706
|
+
return new provider(args);
|
|
707
|
+
}
|
|
662
708
|
static resolveHandler(route) {
|
|
663
709
|
let handlerFunction;
|
|
664
710
|
let instance = null;
|
|
@@ -736,7 +782,7 @@ var CoreRouter = class {
|
|
|
736
782
|
});
|
|
737
783
|
}
|
|
738
784
|
static bindRequestToInstance(ctx, instance, route, payload) {
|
|
739
|
-
const clearRequest = ctx.clearRequest instanceof Request ? ctx.clearRequest :
|
|
785
|
+
const clearRequest = ctx.clearRequest instanceof Request ? ctx.clearRequest : this.initializeInstance(Request, {
|
|
740
786
|
ctx,
|
|
741
787
|
route,
|
|
742
788
|
body: payload.body,
|
|
@@ -756,7 +802,7 @@ var CoreRouter = class {
|
|
|
756
802
|
ctx.clearRequest = clearRequest;
|
|
757
803
|
Container.bind(Request, ctx.clearRequest);
|
|
758
804
|
if (!(ctx.clearResponse instanceof Response)) {
|
|
759
|
-
ctx.clearResponse =
|
|
805
|
+
ctx.clearResponse = this.initializeInstance(Response, ctx.response ?? ctx.reply ?? ctx.res);
|
|
760
806
|
Container.bind(Response, ctx.clearResponse);
|
|
761
807
|
}
|
|
762
808
|
if (!instance) return;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { a as BindValue, i as BindToken, o as Container } from "./bindings-CNL7bpz5.mjs";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
import { EventHandlerRequest, H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
3
|
+
import { EventHandlerRequest, H3, H3Event, Middleware as Middleware$2, TypedServerRequest } from "h3";
|
|
4
4
|
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
5
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
6
|
+
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
7
|
+
import Koa from "koa";
|
|
8
|
+
import Router$1 from "@koa/router";
|
|
5
9
|
|
|
6
10
|
//#region src/core/Response.d.ts
|
|
7
11
|
declare class Response$2 {
|
|
12
|
+
[key: string]: any;
|
|
8
13
|
body: any;
|
|
9
14
|
headers: Headers;
|
|
10
15
|
sent: boolean;
|
|
@@ -63,14 +68,14 @@ interface RouterConfig {
|
|
|
63
68
|
}
|
|
64
69
|
//#endregion
|
|
65
70
|
//#region types/express.d.ts
|
|
66
|
-
interface RequestWithGetBody extends Request {
|
|
71
|
+
interface RequestWithGetBody$3 extends Request {
|
|
67
72
|
getBody: () => Record<string, any>;
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* HTTP context passed to route handlers
|
|
71
76
|
*/
|
|
72
|
-
interface HttpContext$
|
|
73
|
-
req: RequestWithGetBody;
|
|
77
|
+
interface HttpContext$4 {
|
|
78
|
+
req: RequestWithGetBody$3;
|
|
74
79
|
res: Response$1;
|
|
75
80
|
next: NextFunction;
|
|
76
81
|
clearRequest: Request$1;
|
|
@@ -79,12 +84,12 @@ interface HttpContext$1 {
|
|
|
79
84
|
/**
|
|
80
85
|
* Route handler function type
|
|
81
86
|
*/
|
|
82
|
-
type RouteHandler$
|
|
87
|
+
type RouteHandler$4 = (
|
|
83
88
|
/**
|
|
84
89
|
* Express context object containing req, res, and next
|
|
85
90
|
*/
|
|
86
91
|
|
|
87
|
-
ctx: HttpContext$
|
|
92
|
+
ctx: HttpContext$4,
|
|
88
93
|
/**
|
|
89
94
|
* ClearRequest instance
|
|
90
95
|
*/
|
|
@@ -93,11 +98,27 @@ req: Request$1) => any | Promise<any>;
|
|
|
93
98
|
/**
|
|
94
99
|
* Handler can be either a function or controller reference
|
|
95
100
|
*/
|
|
96
|
-
type Handler$
|
|
101
|
+
type Handler$4 = RouteHandler$4 | ControllerHandler;
|
|
97
102
|
/**
|
|
98
103
|
* Middleware function type
|
|
99
104
|
*/
|
|
100
|
-
type Middleware$
|
|
105
|
+
type Middleware$4 = (req: Request, res: Response$1, next: NextFunction) => any | Promise<any>;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region types/fastify.d.ts
|
|
108
|
+
interface RequestWithGetBody$2 extends FastifyRequest {
|
|
109
|
+
getBody: () => Record<string, any>;
|
|
110
|
+
}
|
|
111
|
+
interface HttpContext$3 {
|
|
112
|
+
req: RequestWithGetBody$2;
|
|
113
|
+
reply: FastifyReply;
|
|
114
|
+
clearRequest: Request$1;
|
|
115
|
+
clearResponse: Response$2;
|
|
116
|
+
}
|
|
117
|
+
type RouteHandler$3 = (ctx: HttpContext$3, req: Request$1) => any | Promise<any>;
|
|
118
|
+
type Handler$3 = RouteHandler$3 | ControllerHandler;
|
|
119
|
+
type NextFunction$1 = (err?: Error) => void;
|
|
120
|
+
type Middleware$3 = (req: RequestWithGetBody$2, reply: FastifyReply, next: NextFunction$1) => any | Promise<any>;
|
|
121
|
+
type FastifyApp = FastifyInstance;
|
|
101
122
|
//#endregion
|
|
102
123
|
//#region types/h3.d.ts
|
|
103
124
|
type H3App = Omit<H3, 'fetch'> & {
|
|
@@ -110,7 +131,7 @@ type RequestlessH3Event = Omit<H3Event, 'req'>;
|
|
|
110
131
|
/**
|
|
111
132
|
* HTTP context passed to route handlers
|
|
112
133
|
*/
|
|
113
|
-
interface HttpContext extends RequestlessH3Event {
|
|
134
|
+
interface HttpContext$2 extends RequestlessH3Event {
|
|
114
135
|
req: HttpRequest;
|
|
115
136
|
clearRequest: Request$1;
|
|
116
137
|
clearResponse: Response$2;
|
|
@@ -118,12 +139,12 @@ interface HttpContext extends RequestlessH3Event {
|
|
|
118
139
|
/**
|
|
119
140
|
* Route handler function type
|
|
120
141
|
*/
|
|
121
|
-
type RouteHandler = (
|
|
142
|
+
type RouteHandler$2 = (
|
|
122
143
|
/**
|
|
123
144
|
* H3 event context
|
|
124
145
|
*/
|
|
125
146
|
|
|
126
|
-
ctx: HttpContext,
|
|
147
|
+
ctx: HttpContext$2,
|
|
127
148
|
/**
|
|
128
149
|
* ClearRequest instance
|
|
129
150
|
*/
|
|
@@ -132,7 +153,38 @@ req: Request$1) => any | Promise<any>;
|
|
|
132
153
|
/**
|
|
133
154
|
* Handler can be either a function or controller reference
|
|
134
155
|
*/
|
|
156
|
+
type Handler$2 = RouteHandler$2 | ControllerHandler;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region types/hono.d.ts
|
|
159
|
+
type RequestWithGetBody$1 = HonoRequest & {
|
|
160
|
+
getBody: () => Record<string, any>;
|
|
161
|
+
};
|
|
162
|
+
type HttpContext$1 = Context & {
|
|
163
|
+
req: RequestWithGetBody$1;
|
|
164
|
+
clearRequest: Request$1;
|
|
165
|
+
clearResponse: Response$2;
|
|
166
|
+
};
|
|
167
|
+
type RouteHandler$1 = (ctx: HttpContext$1, req: Request$1) => any | Promise<any>;
|
|
168
|
+
type Handler$1 = RouteHandler$1 | ControllerHandler;
|
|
169
|
+
type Middleware$1 = MiddlewareHandler;
|
|
170
|
+
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: Middleware$1[]) => any };
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region types/koa.d.ts
|
|
173
|
+
interface RequestWithGetBody extends Koa.Request {
|
|
174
|
+
getBody: () => Record<string, any>;
|
|
175
|
+
body?: any;
|
|
176
|
+
}
|
|
177
|
+
interface HttpContext extends Koa.Context {
|
|
178
|
+
request: RequestWithGetBody;
|
|
179
|
+
clearRequest: Request$1;
|
|
180
|
+
clearResponse: Response$2;
|
|
181
|
+
params: Record<string, any>;
|
|
182
|
+
query: Record<string, any>;
|
|
183
|
+
}
|
|
184
|
+
type RouteHandler = (ctx: HttpContext, req: Request$1) => any | Promise<any>;
|
|
135
185
|
type Handler = RouteHandler | ControllerHandler;
|
|
186
|
+
type Middleware = Koa.Middleware<any, any>;
|
|
187
|
+
type KoaRouterApp = Router$1<any, any>;
|
|
136
188
|
//#endregion
|
|
137
189
|
//#region src/Route.d.ts
|
|
138
190
|
interface RouteParameter {
|
|
@@ -140,7 +192,7 @@ interface RouteParameter {
|
|
|
140
192
|
field?: string;
|
|
141
193
|
optional: boolean;
|
|
142
194
|
}
|
|
143
|
-
declare class Route<X = any, M = Middleware | Middleware$
|
|
195
|
+
declare class Route<X = any, M = Middleware$2 | Middleware$4, H = any> {
|
|
144
196
|
ctx: X;
|
|
145
197
|
body: RequestData;
|
|
146
198
|
query: RequestData;
|
|
@@ -168,7 +220,7 @@ declare class Route<X = any, M = Middleware | Middleware$1, H = any> {
|
|
|
168
220
|
}
|
|
169
221
|
//#endregion
|
|
170
222
|
//#region src/ClearRequest.d.ts
|
|
171
|
-
declare class ClearRequest<X = any, M = Middleware | Middleware$1> {
|
|
223
|
+
declare class ClearRequest<X = any, M = Middleware$2 | Middleware$4 | Middleware$3 | Middleware$1 | Middleware> {
|
|
172
224
|
[key: string]: any;
|
|
173
225
|
/**
|
|
174
226
|
* @param body - Parsed request body
|
|
@@ -272,6 +324,12 @@ declare abstract class CoreRouter {
|
|
|
272
324
|
private static readonly pluginStoreKey;
|
|
273
325
|
private static readonly pluginPendingKey;
|
|
274
326
|
private static readonly pluginArgumentResolversKey;
|
|
327
|
+
private static requestProvider?;
|
|
328
|
+
private static responseProvider?;
|
|
329
|
+
/**
|
|
330
|
+
* Resets the router to it's default state
|
|
331
|
+
*/
|
|
332
|
+
static reset(): typeof CoreRouter;
|
|
275
333
|
protected static createBaseConfig(): RouterConfig;
|
|
276
334
|
protected static mergeConfig(target: RouterConfig, source?: RouterConfig): RouterConfig;
|
|
277
335
|
protected static getDefaultConfig(): RouterConfig;
|
|
@@ -472,6 +530,24 @@ declare abstract class CoreRouter {
|
|
|
472
530
|
static allRoutes(type: 'name'): Record<string, Route<any, any, any>>;
|
|
473
531
|
static route(name: string): Route<any, any, any> | undefined;
|
|
474
532
|
static url(name: string, params?: Record<string, any>): string | undefined;
|
|
533
|
+
/**
|
|
534
|
+
* Provide a class that will overide the base Request instance
|
|
535
|
+
*
|
|
536
|
+
* @param provider
|
|
537
|
+
*/
|
|
538
|
+
static setRequestProvider(provider: typeof Request$1): void;
|
|
539
|
+
/**
|
|
540
|
+
* Provide a class that will overide the base Response instance
|
|
541
|
+
*
|
|
542
|
+
* @param provider
|
|
543
|
+
*/
|
|
544
|
+
static setResponseProvider(provider: typeof Response$2): void;
|
|
545
|
+
/**
|
|
546
|
+
* Provide a class that will overide the base Response instance
|
|
547
|
+
*
|
|
548
|
+
* @param provider
|
|
549
|
+
*/
|
|
550
|
+
private static initializeInstance;
|
|
475
551
|
protected static resolveHandler(route: Route<any, any, any>): {
|
|
476
552
|
handlerFunction: ((ctx: any, req: Request$1) => any | Promise<any>) | null;
|
|
477
553
|
instance: Controller<any> | null;
|
|
@@ -489,4 +565,4 @@ declare abstract class CoreRouter {
|
|
|
489
565
|
}): void;
|
|
490
566
|
}
|
|
491
567
|
//#endregion
|
|
492
|
-
export {
|
|
568
|
+
export { Middleware$3 as A, H3App as C, FastifyApp as D, Middleware$2 as E, ControllerAction as F, HttpMethod as I, Response$2 as L, HttpContext$4 as M, Middleware$4 as N, Handler$3 as O, ApiResourceMiddleware as P, Middleware$1 as S, HttpContext$2 as T, KoaRouterApp as _, ClearRouterPluginInput as a, HonoApp as b, PluginBind as c, PluginSetupResult as d, definePlugin as f, HttpContext as g, Handler as h, ClearRouterPluginContext as i, Handler$4 as j, HttpContext$3 as k, PluginBindFactory as l, Route as m, ClearRouterPlugin as n, ClearRouterPluginRequestContext as o, Request$1 as p, ClearRouterPluginArgumentsContext as r, PluginArgumentsResolver as s, CoreRouter as t, PluginBindValue as u, Middleware as v, Handler$2 as w, HttpContext$1 as x, Handler$1 as y };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { RequestData } from "../types/basic.mjs";
|
|
2
|
-
import { Middleware } from "../types/
|
|
2
|
+
import { Middleware } from "../types/fastify.mjs";
|
|
3
|
+
import { Middleware as Middleware$1 } from "../types/h3.mjs";
|
|
4
|
+
import { Middleware as Middleware$2 } from "../types/hono.mjs";
|
|
5
|
+
import { Middleware as Middleware$3 } from "../types/koa.mjs";
|
|
3
6
|
import { Route } from "./Route.mjs";
|
|
4
|
-
import { Middleware as Middleware$
|
|
7
|
+
import { Middleware as Middleware$4 } from "../types/express.mjs";
|
|
5
8
|
|
|
6
9
|
//#region src/ClearRequest.d.ts
|
|
7
|
-
declare class ClearRequest<X = any, M = Middleware | Middleware$
|
|
10
|
+
declare class ClearRequest<X = any, M = Middleware$1 | Middleware$4 | Middleware | Middleware$2 | Middleware$3> {
|
|
8
11
|
[key: string]: any;
|
|
9
12
|
/**
|
|
10
13
|
* @param body - Parsed request body
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clear-router",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
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",
|
|
@@ -141,7 +141,8 @@
|
|
|
141
141
|
"node": ">=20.0.0"
|
|
142
142
|
},
|
|
143
143
|
"scripts": {
|
|
144
|
-
"test": "vitest",
|
|
144
|
+
"test": "vitest run",
|
|
145
|
+
"test:watch": "vitest --watch",
|
|
145
146
|
"lint": "eslint",
|
|
146
147
|
"docs:dev": "vitepress dev docs",
|
|
147
148
|
"docs:build": "vitepress build docs",
|