clear-router 2.8.3 → 2.8.4
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 +6 -6
- package/dist/Controller.d.cts +1 -1
- package/dist/ResourceRouteSelection.d.cts +3 -3
- package/dist/ResourceRoutes.d.cts +3 -3
- package/dist/Route.d.cts +4 -4
- package/dist/RouteGroup.cjs +36 -6
- package/dist/RouteGroup.d.cts +14 -5
- package/dist/RouteGroup.d.mts +11 -2
- package/dist/RouteGroup.mjs +36 -6
- package/dist/core/CoreRouter.d.cts +3 -3
- package/dist/core/Request.d.cts +1 -1
- package/dist/core/bindings.d.cts +6 -1
- package/dist/core/plugins.d.cts +1 -1
- package/dist/types/basic.d.cts +6 -2
- package/dist/types/basic.d.mts +1 -1
- package/dist/types/express.d.cts +36 -2
- package/dist/types/fastify.d.cts +15 -3
- package/dist/types/h3.d.cts +38 -3
- package/dist/types/hono.d.cts +17 -3
- package/dist/types/koa.d.cts +20 -2
- package/package.json +1 -1
package/dist/ClearRequest.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Middleware } from "./types/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Middleware as Middleware$1 } from "./types/express.cjs";
|
|
5
|
-
import { Middleware as Middleware$2 } from "./types/fastify.cjs";
|
|
1
|
+
import { Middleware } from "./types/express.cjs";
|
|
2
|
+
import { Middleware as Middleware$1 } from "./types/fastify.cjs";
|
|
3
|
+
import { Middleware as Middleware$2 } from "./types/h3.cjs";
|
|
6
4
|
import { Middleware as Middleware$3 } from "./types/hono.cjs";
|
|
7
5
|
import { Middleware as Middleware$4 } from "./types/koa.cjs";
|
|
6
|
+
import { Route } from "./Route.cjs";
|
|
7
|
+
import { RequestData } from "./types/basic.cjs";
|
|
8
8
|
|
|
9
9
|
//#region src/ClearRequest.d.ts
|
|
10
|
-
declare class ClearRequest<X = any, M = Middleware | Middleware
|
|
10
|
+
declare class ClearRequest<X = any, M = Middleware$2 | Middleware | Middleware$1 | Middleware$3 | Middleware$4> {
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
/**
|
|
13
13
|
* @param body - Parsed request body
|
package/dist/Controller.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Middleware } from "./types/
|
|
1
|
+
import { Middleware } from "./types/express.cjs";
|
|
2
|
+
import { Middleware as Middleware$1 } from "./types/h3.cjs";
|
|
2
3
|
import { Route } from "./Route.cjs";
|
|
3
|
-
import { Middleware as Middleware$1 } from "./types/express.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/ResourceRouteSelection.d.ts
|
|
6
|
-
declare class ResourceRouteSelection<X = any, M = Middleware | Middleware
|
|
6
|
+
declare class ResourceRouteSelection<X = any, M = Middleware$1 | Middleware, H = any> {
|
|
7
7
|
readonly routes: Array<Route<X, M, H>>;
|
|
8
8
|
constructor(routes: Array<Route<X, M, H>>);
|
|
9
9
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Middleware } from "./types/
|
|
1
|
+
import { Middleware } from "./types/express.cjs";
|
|
2
|
+
import { Middleware as Middleware$1 } from "./types/h3.cjs";
|
|
2
3
|
import { Route } from "./Route.cjs";
|
|
3
4
|
import { ApiResourceMiddleware, HttpMethod, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions } from "./types/basic.cjs";
|
|
4
|
-
import { Middleware as Middleware$1 } from "./types/express.cjs";
|
|
5
5
|
import { ResourceRouteSelection } from "./ResourceRouteSelection.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/ResourceRoutes.d.ts
|
|
@@ -11,7 +11,7 @@ import { ResourceRouteSelection } from "./ResourceRouteSelection.cjs";
|
|
|
11
11
|
* @author 3m1n3nc3
|
|
12
12
|
* @repository https://github.com/arkstack-tmp/clear-router
|
|
13
13
|
*/
|
|
14
|
-
declare class ResourceRoutes<X = any, M = Middleware | Middleware
|
|
14
|
+
declare class ResourceRoutes<X = any, M = Middleware$1 | Middleware, H = any> {
|
|
15
15
|
readonly basePath: string;
|
|
16
16
|
readonly controller: any;
|
|
17
17
|
readonly paramName: string;
|
package/dist/Route.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RouteParameter } from "./Contracts.cjs";
|
|
2
|
-
import { Middleware } from "./types/
|
|
3
|
-
import {
|
|
4
|
-
import { Middleware as Middleware$1 } from "./types/express.cjs";
|
|
2
|
+
import { Middleware } from "./types/express.cjs";
|
|
3
|
+
import { Middleware as Middleware$1 } from "./types/h3.cjs";
|
|
5
4
|
import { ClearRequest } from "./ClearRequest.cjs";
|
|
5
|
+
import { HttpMethod, RequestData } from "./types/basic.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/Route.d.ts
|
|
8
8
|
/**
|
|
@@ -11,7 +11,7 @@ import { ClearRequest } from "./ClearRequest.cjs";
|
|
|
11
11
|
* @author 3m1n3nc3
|
|
12
12
|
* @repository https://github.com/arkstack-tmp/clear-router
|
|
13
13
|
*/
|
|
14
|
-
declare class Route<X = any, M = Middleware | Middleware
|
|
14
|
+
declare class Route<X = any, M = Middleware$1 | Middleware, H = any> {
|
|
15
15
|
ctx: X;
|
|
16
16
|
body: RequestData;
|
|
17
17
|
query: RequestData;
|
package/dist/RouteGroup.cjs
CHANGED
|
@@ -11,8 +11,10 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
11
11
|
*/
|
|
12
12
|
var RouteGroup = class {
|
|
13
13
|
checks = [];
|
|
14
|
+
conditions = [];
|
|
14
15
|
registration;
|
|
15
16
|
routes = /* @__PURE__ */ new Set();
|
|
17
|
+
unfilteredSources = /* @__PURE__ */ new Set();
|
|
16
18
|
constructor(options) {
|
|
17
19
|
this.options = options;
|
|
18
20
|
this.registration = this.register();
|
|
@@ -24,8 +26,13 @@ var RouteGroup = class {
|
|
|
24
26
|
* @returns
|
|
25
27
|
*/
|
|
26
28
|
when(condition) {
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
+
this.conditions.push(condition);
|
|
30
|
+
const unfilteredSources = Array.from(this.unfilteredSources);
|
|
31
|
+
if (unfilteredSources.length) this.checks.push(this.registration.then(async () => {
|
|
32
|
+
for (const source of unfilteredSources) if (!await condition(source)) {
|
|
33
|
+
this.rollback();
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
29
36
|
}));
|
|
30
37
|
return this;
|
|
31
38
|
}
|
|
@@ -67,20 +74,37 @@ var RouteGroup = class {
|
|
|
67
74
|
await this.options.context.run(nextContext, async () => {
|
|
68
75
|
for (const entry of Array.isArray(this.options.source) ? this.options.source : [this.options.source]) {
|
|
69
76
|
if (typeof entry === "function") {
|
|
77
|
+
if (!this.conditions.length) this.unfilteredSources.add(entry);
|
|
78
|
+
else if (!await this.accepts(entry)) continue;
|
|
70
79
|
await Promise.resolve(entry());
|
|
71
80
|
continue;
|
|
72
81
|
}
|
|
73
|
-
|
|
82
|
+
const resolved = await this.resolveFiles(entry);
|
|
83
|
+
if (!resolved.directory && !await this.accepts(entry)) continue;
|
|
84
|
+
for (const file of resolved.files) {
|
|
85
|
+
if (resolved.directory && !await this.accepts(file)) continue;
|
|
86
|
+
await require_helpers.importFile(file);
|
|
87
|
+
}
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
91
|
/**
|
|
78
|
-
* Rollback the route
|
|
92
|
+
* Rollback the route registration
|
|
79
93
|
*/
|
|
80
94
|
rollback() {
|
|
81
95
|
for (const route of this.routes) this.options.removeRoute(route);
|
|
82
96
|
}
|
|
83
97
|
/**
|
|
98
|
+
* Check whether a callback or path should be registered.
|
|
99
|
+
*
|
|
100
|
+
* @param source
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
async accepts(source) {
|
|
104
|
+
for (const condition of this.conditions) if (!await condition(source)) return false;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
84
108
|
* Resolve files from the group path
|
|
85
109
|
*
|
|
86
110
|
* @param source
|
|
@@ -94,9 +118,15 @@ var RouteGroup = class {
|
|
|
94
118
|
} catch {
|
|
95
119
|
throw new Error(`Route group source not found: ${source}`);
|
|
96
120
|
}
|
|
97
|
-
if (sourceStat.isFile()) return
|
|
121
|
+
if (sourceStat.isFile()) return {
|
|
122
|
+
directory: false,
|
|
123
|
+
files: [resolved]
|
|
124
|
+
};
|
|
98
125
|
if (!sourceStat.isDirectory()) throw new Error(`Route group source must be a file or directory: ${source}`);
|
|
99
|
-
return
|
|
126
|
+
return {
|
|
127
|
+
directory: true,
|
|
128
|
+
files: await this.readDirectory(resolved)
|
|
129
|
+
};
|
|
100
130
|
}
|
|
101
131
|
/**
|
|
102
132
|
* Read all the files in the configured directory
|
package/dist/RouteGroup.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Middleware } from "./types/
|
|
1
|
+
import { Middleware } from "./types/express.cjs";
|
|
2
|
+
import { Middleware as Middleware$1 } from "./types/h3.cjs";
|
|
2
3
|
import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.cjs";
|
|
3
|
-
import { Middleware as Middleware$1 } from "./types/express.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/RouteGroup.d.ts
|
|
6
6
|
/**
|
|
@@ -9,11 +9,13 @@ import { Middleware as Middleware$1 } from "./types/express.cjs";
|
|
|
9
9
|
* @author 3m1n3nc3
|
|
10
10
|
* @repository https://github.com/arkstack-tmp/clear-router
|
|
11
11
|
*/
|
|
12
|
-
declare class RouteGroup<X = any, M = Middleware | Middleware
|
|
12
|
+
declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implements PromiseLike<void> {
|
|
13
13
|
private readonly options;
|
|
14
14
|
private readonly checks;
|
|
15
|
+
private readonly conditions;
|
|
15
16
|
private readonly registration;
|
|
16
17
|
private readonly routes;
|
|
18
|
+
private readonly unfilteredSources;
|
|
17
19
|
constructor(options: RouteGroupOptions);
|
|
18
20
|
/**
|
|
19
21
|
* Returning a falsy value will stop route group registration
|
|
@@ -42,9 +44,16 @@ declare class RouteGroup<X = any, M = Middleware | Middleware$1, H = any> implem
|
|
|
42
44
|
*/
|
|
43
45
|
private register;
|
|
44
46
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
* Rollback the route registration
|
|
48
|
+
*/
|
|
47
49
|
private rollback;
|
|
50
|
+
/**
|
|
51
|
+
* Check whether a callback or path should be registered.
|
|
52
|
+
*
|
|
53
|
+
* @param source
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
private accepts;
|
|
48
57
|
/**
|
|
49
58
|
* Resolve files from the group path
|
|
50
59
|
*
|
package/dist/RouteGroup.d.mts
CHANGED
|
@@ -12,8 +12,10 @@ import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.mjs";
|
|
|
12
12
|
declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implements PromiseLike<void> {
|
|
13
13
|
private readonly options;
|
|
14
14
|
private readonly checks;
|
|
15
|
+
private readonly conditions;
|
|
15
16
|
private readonly registration;
|
|
16
17
|
private readonly routes;
|
|
18
|
+
private readonly unfilteredSources;
|
|
17
19
|
constructor(options: RouteGroupOptions);
|
|
18
20
|
/**
|
|
19
21
|
* Returning a falsy value will stop route group registration
|
|
@@ -42,9 +44,16 @@ declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implem
|
|
|
42
44
|
*/
|
|
43
45
|
private register;
|
|
44
46
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
* Rollback the route registration
|
|
48
|
+
*/
|
|
47
49
|
private rollback;
|
|
50
|
+
/**
|
|
51
|
+
* Check whether a callback or path should be registered.
|
|
52
|
+
*
|
|
53
|
+
* @param source
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
private accepts;
|
|
48
57
|
/**
|
|
49
58
|
* Resolve files from the group path
|
|
50
59
|
*
|
package/dist/RouteGroup.mjs
CHANGED
|
@@ -11,8 +11,10 @@ import { readdir, stat } from "node:fs/promises";
|
|
|
11
11
|
*/
|
|
12
12
|
var RouteGroup = class {
|
|
13
13
|
checks = [];
|
|
14
|
+
conditions = [];
|
|
14
15
|
registration;
|
|
15
16
|
routes = /* @__PURE__ */ new Set();
|
|
17
|
+
unfilteredSources = /* @__PURE__ */ new Set();
|
|
16
18
|
constructor(options) {
|
|
17
19
|
this.options = options;
|
|
18
20
|
this.registration = this.register();
|
|
@@ -24,8 +26,13 @@ var RouteGroup = class {
|
|
|
24
26
|
* @returns
|
|
25
27
|
*/
|
|
26
28
|
when(condition) {
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
+
this.conditions.push(condition);
|
|
30
|
+
const unfilteredSources = Array.from(this.unfilteredSources);
|
|
31
|
+
if (unfilteredSources.length) this.checks.push(this.registration.then(async () => {
|
|
32
|
+
for (const source of unfilteredSources) if (!await condition(source)) {
|
|
33
|
+
this.rollback();
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
29
36
|
}));
|
|
30
37
|
return this;
|
|
31
38
|
}
|
|
@@ -67,20 +74,37 @@ var RouteGroup = class {
|
|
|
67
74
|
await this.options.context.run(nextContext, async () => {
|
|
68
75
|
for (const entry of Array.isArray(this.options.source) ? this.options.source : [this.options.source]) {
|
|
69
76
|
if (typeof entry === "function") {
|
|
77
|
+
if (!this.conditions.length) this.unfilteredSources.add(entry);
|
|
78
|
+
else if (!await this.accepts(entry)) continue;
|
|
70
79
|
await Promise.resolve(entry());
|
|
71
80
|
continue;
|
|
72
81
|
}
|
|
73
|
-
|
|
82
|
+
const resolved = await this.resolveFiles(entry);
|
|
83
|
+
if (!resolved.directory && !await this.accepts(entry)) continue;
|
|
84
|
+
for (const file of resolved.files) {
|
|
85
|
+
if (resolved.directory && !await this.accepts(file)) continue;
|
|
86
|
+
await importFile(file);
|
|
87
|
+
}
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
91
|
/**
|
|
78
|
-
* Rollback the route
|
|
92
|
+
* Rollback the route registration
|
|
79
93
|
*/
|
|
80
94
|
rollback() {
|
|
81
95
|
for (const route of this.routes) this.options.removeRoute(route);
|
|
82
96
|
}
|
|
83
97
|
/**
|
|
98
|
+
* Check whether a callback or path should be registered.
|
|
99
|
+
*
|
|
100
|
+
* @param source
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
async accepts(source) {
|
|
104
|
+
for (const condition of this.conditions) if (!await condition(source)) return false;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
84
108
|
* Resolve files from the group path
|
|
85
109
|
*
|
|
86
110
|
* @param source
|
|
@@ -94,9 +118,15 @@ var RouteGroup = class {
|
|
|
94
118
|
} catch {
|
|
95
119
|
throw new Error(`Route group source not found: ${source}`);
|
|
96
120
|
}
|
|
97
|
-
if (sourceStat.isFile()) return
|
|
121
|
+
if (sourceStat.isFile()) return {
|
|
122
|
+
directory: false,
|
|
123
|
+
files: [resolved]
|
|
124
|
+
};
|
|
98
125
|
if (!sourceStat.isDirectory()) throw new Error(`Route group source must be a file or directory: ${source}`);
|
|
99
|
-
return
|
|
126
|
+
return {
|
|
127
|
+
directory: true,
|
|
128
|
+
files: await this.readDirectory(resolved)
|
|
129
|
+
};
|
|
100
130
|
}
|
|
101
131
|
/**
|
|
102
132
|
* Read all the files in the configured directory
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Request } from "./Request.cjs";
|
|
2
1
|
import { Response } from "./Response.cjs";
|
|
3
2
|
import { Route } from "../Route.cjs";
|
|
4
3
|
import { ApiResourceMiddleware, HttpMethod, ResourceAction, RouteGroupContext, RouteGroupSource, RouterConfig } from "../types/basic.cjs";
|
|
5
|
-
import {
|
|
6
|
-
import { RouteGroup } from "../RouteGroup.cjs";
|
|
4
|
+
import { Request } from "./Request.cjs";
|
|
7
5
|
import { ClearRouterPluginArgumentsContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, PluginArgumentsResolver, PluginBind } from "./plugins.cjs";
|
|
6
|
+
import { Controller } from "../Controller.cjs";
|
|
8
7
|
import { ResourceRoutes } from "../ResourceRoutes.cjs";
|
|
8
|
+
import { RouteGroup } from "../RouteGroup.cjs";
|
|
9
9
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
10
|
|
|
11
11
|
//#region src/core/CoreRouter.d.ts
|
package/dist/core/Request.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ClearRequest } from "../ClearRequest.cjs";
|
|
1
2
|
import { Route } from "../Route.cjs";
|
|
2
3
|
import { HttpMethod, RequestData } from "../types/basic.cjs";
|
|
3
|
-
import { ClearRequest } from "../ClearRequest.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/core/Request.d.ts
|
|
6
6
|
declare class Request<X = any, M = any> extends ClearRequest<X, M> {
|
package/dist/core/bindings.d.cts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
type BindToken<T = any> = abstract new (...args: any[]) => T;
|
|
3
3
|
type BindFactory<T = any> = (ctx: any) => T | Promise<T>;
|
|
4
4
|
type BindValue<T = any> = T | BindFactory<T> | BindToken<T>;
|
|
5
|
+
type BindDecorator = MethodDecorator & ClassDecorator & {
|
|
6
|
+
<This, Value extends (this: This, ...args: any[]) => any>(value: Value, context: ClassMethodDecoratorContext<This, Value>): void | Value;
|
|
7
|
+
<Value extends abstract new (...args: any[]) => any>(value: Value, context: ClassDecoratorContext<Value>): void | Value;
|
|
8
|
+
};
|
|
5
9
|
declare class Container {
|
|
6
10
|
private static readonly registry;
|
|
7
11
|
static bind<T>(token: BindToken<T>, value: BindValue<T>): void;
|
|
@@ -16,5 +20,6 @@ declare class Container {
|
|
|
16
20
|
private static staticPropsMatch;
|
|
17
21
|
private static resolveBinding;
|
|
18
22
|
}
|
|
23
|
+
declare function Bind(...tokens: BindToken[]): BindDecorator;
|
|
19
24
|
//#endregion
|
|
20
|
-
export { BindToken, BindValue, Container };
|
|
25
|
+
export { Bind, BindDecorator, BindFactory, BindToken, BindValue, Container };
|
package/dist/core/plugins.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Request } from "./Request.cjs";
|
|
2
1
|
import { Response } from "./Response.cjs";
|
|
3
2
|
import { RouterConfig } from "../types/basic.cjs";
|
|
3
|
+
import { Request } from "./Request.cjs";
|
|
4
4
|
import { BindToken, BindValue, Container } from "./bindings.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/core/plugins.d.ts
|
package/dist/types/basic.d.cts
CHANGED
|
@@ -3,6 +3,10 @@ import { JitiOptions, JitiResolveOptions } from "jiti";
|
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
|
|
5
5
|
//#region src/types/basic.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Controller method reference
|
|
8
|
+
*/
|
|
9
|
+
type ControllerHandler = [any, string];
|
|
6
10
|
type MaybePromise<T = any> = T | Promise<T>;
|
|
7
11
|
type RouteGroupCallback = () => MaybePromise<any>;
|
|
8
12
|
type RouteGroupEntry = RouteGroupCallback | string;
|
|
@@ -84,7 +88,7 @@ interface RouteGroupOptions {
|
|
|
84
88
|
normalizePath: (path: string) => string;
|
|
85
89
|
removeRoute: (route: Route<any, any, any>) => void;
|
|
86
90
|
}
|
|
87
|
-
type RouteGroupCondition = (source:
|
|
91
|
+
type RouteGroupCondition = (source: RouteGroupEntry) => MaybePromise<unknown>;
|
|
88
92
|
interface FileImporter {
|
|
89
93
|
<T = unknown>(filePath: string): Promise<T>;
|
|
90
94
|
<T = unknown>(filePath: string, userOptions?: JitiOptions | undefined): Promise<T>;
|
|
@@ -93,4 +97,4 @@ interface FileImporter {
|
|
|
93
97
|
})): Promise<T>;
|
|
94
98
|
}
|
|
95
99
|
//#endregion
|
|
96
|
-
export { ApiResourceMiddleware, ClassMiddleware, FileImporter, HttpMethod, MiddlewareHandle, RequestData, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions, RouteGroupCondition, RouteGroupContext, RouteGroupOptions, RouteGroupSource, RouterConfig };
|
|
100
|
+
export { ApiResourceMiddleware, ClassMiddleware, ControllerHandler, FileImporter, HttpMethod, MiddlewareHandle, RequestData, ResourceAction, ResourceRouteDefinition, ResourceRouteRegistrar, ResourceRouteRemover, ResourceRoutesOptions, RouteGroupCondition, RouteGroupContext, RouteGroupOptions, RouteGroupSource, RouterConfig };
|
package/dist/types/basic.d.mts
CHANGED
|
@@ -88,7 +88,7 @@ interface RouteGroupOptions {
|
|
|
88
88
|
normalizePath: (path: string) => string;
|
|
89
89
|
removeRoute: (route: Route<any, any, any>) => void;
|
|
90
90
|
}
|
|
91
|
-
type RouteGroupCondition = (source:
|
|
91
|
+
type RouteGroupCondition = (source: RouteGroupEntry) => MaybePromise<unknown>;
|
|
92
92
|
interface FileImporter {
|
|
93
93
|
<T = unknown>(filePath: string): Promise<T>;
|
|
94
94
|
<T = unknown>(filePath: string, userOptions?: JitiOptions | undefined): Promise<T>;
|
package/dist/types/express.d.cts
CHANGED
|
@@ -1,7 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
2
|
+
import { Response as Response$1 } from "../core/Response.cjs";
|
|
3
|
+
import { ClassMiddleware, ControllerHandler, MiddlewareHandle } from "./basic.cjs";
|
|
4
|
+
import { Request as Request$1 } from "../core/Request.cjs";
|
|
2
5
|
import { NextFunction, Request, Response } from "express";
|
|
3
6
|
|
|
4
7
|
//#region src/types/express.d.ts
|
|
8
|
+
interface RequestWithGetBody extends Request {
|
|
9
|
+
getBody: () => Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* HTTP context passed to route handlers
|
|
13
|
+
*/
|
|
14
|
+
interface HttpContext extends ClearHttpContext {
|
|
15
|
+
req: RequestWithGetBody;
|
|
16
|
+
res: Response;
|
|
17
|
+
next: NextFunction;
|
|
18
|
+
clearRequest: Request$1;
|
|
19
|
+
clearResponse: Response$1;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Route handler function type
|
|
23
|
+
*/
|
|
24
|
+
type RouteHandler = (
|
|
25
|
+
/**
|
|
26
|
+
* Express context object containing req, res, and next
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
ctx: HttpContext,
|
|
30
|
+
/**
|
|
31
|
+
* ClearRequest instance
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
req: Request$1) => any | Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Handler can be either a function or controller reference
|
|
37
|
+
*/
|
|
38
|
+
type Handler = RouteHandler | ControllerHandler;
|
|
5
39
|
/**
|
|
6
40
|
* Middleware function type
|
|
7
41
|
*/
|
|
@@ -11,4 +45,4 @@ type MiddlewareFunction = MiddlewareHandle<[Request, Response, NextFunction]>;
|
|
|
11
45
|
*/
|
|
12
46
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
13
47
|
//#endregion
|
|
14
|
-
export { Middleware };
|
|
48
|
+
export { Handler, HttpContext, Middleware };
|
package/dist/types/fastify.d.cts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
2
|
+
import { Response } from "../core/Response.cjs";
|
|
3
|
+
import { ClassMiddleware, ControllerHandler, MiddlewareHandle } from "./basic.cjs";
|
|
4
|
+
import { Request } from "../core/Request.cjs";
|
|
5
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
3
6
|
|
|
4
7
|
//#region src/types/fastify.d.ts
|
|
5
8
|
interface RequestWithGetBody extends FastifyRequest {
|
|
6
9
|
getBody: () => Record<string, any>;
|
|
7
10
|
}
|
|
11
|
+
interface HttpContext extends ClearHttpContext {
|
|
12
|
+
req: RequestWithGetBody;
|
|
13
|
+
reply: FastifyReply;
|
|
14
|
+
clearRequest: Request;
|
|
15
|
+
clearResponse: Response;
|
|
16
|
+
}
|
|
17
|
+
type RouteHandler = (ctx: HttpContext, req: Request) => any | Promise<any>;
|
|
18
|
+
type Handler = RouteHandler | ControllerHandler;
|
|
8
19
|
type NextFunction = (err?: Error) => void;
|
|
9
20
|
type MiddlewareFunction = MiddlewareHandle<[req: RequestWithGetBody, reply: FastifyReply, next: NextFunction]>;
|
|
10
21
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
22
|
+
type FastifyApp = FastifyInstance;
|
|
11
23
|
//#endregion
|
|
12
|
-
export { Middleware };
|
|
24
|
+
export { FastifyApp, Handler, HttpContext, Middleware };
|
package/dist/types/h3.d.cts
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
2
|
+
import { Response as Response$1 } from "../core/Response.cjs";
|
|
3
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.cjs";
|
|
4
|
+
import { Request } from "../core/Request.cjs";
|
|
5
|
+
import { EventHandlerRequest, H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
3
6
|
|
|
4
7
|
//#region src/types/h3.d.ts
|
|
8
|
+
type H3App = Omit<H3, 'fetch'> & {
|
|
9
|
+
fetch: (request: TypedServerRequest<EventHandlerRequest>) => Promise<Response>;
|
|
10
|
+
};
|
|
11
|
+
interface HttpRequest extends TypedServerRequest<EventHandlerRequest> {
|
|
12
|
+
getBody: () => Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* HTTP context passed to route handlers
|
|
16
|
+
*/
|
|
17
|
+
interface HttpContext extends Omit<H3Event, 'req'>, ClearHttpContext {
|
|
18
|
+
req: HttpRequest;
|
|
19
|
+
clearRequest: Request;
|
|
20
|
+
clearResponse: Response$1;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Route handler function type
|
|
24
|
+
*/
|
|
25
|
+
type RouteHandler = (
|
|
26
|
+
/**
|
|
27
|
+
* H3 event context
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
ctx: HttpContext,
|
|
31
|
+
/**
|
|
32
|
+
* ClearRequest instance
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
req: Request) => any | Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* Handler can be either a function or controller reference
|
|
38
|
+
*/
|
|
39
|
+
type Handler = RouteHandler | ControllerHandler;
|
|
5
40
|
/**
|
|
6
41
|
* Middleware function type
|
|
7
42
|
*/
|
|
8
43
|
type MiddlewareFunction = Middleware;
|
|
9
44
|
type Middleware$1 = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
10
45
|
//#endregion
|
|
11
|
-
export { Middleware$1 as Middleware };
|
|
46
|
+
export { H3App, Handler, HttpContext, Middleware$1 as Middleware };
|
package/dist/types/hono.d.cts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
2
|
+
import { Response } from "../core/Response.cjs";
|
|
3
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.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 = RouteHandler | ControllerHandler;
|
|
5
18
|
type MiddlewareFunction = MiddlewareHandler;
|
|
6
19
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
20
|
+
type HonoApp = { [K in 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head']: (path: string, ...handlers: MiddlewareFunction[]) => any };
|
|
7
21
|
//#endregion
|
|
8
|
-
export { Middleware };
|
|
22
|
+
export { Handler, HonoApp, HttpContext, Middleware };
|
package/dist/types/koa.d.cts
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClearHttpContext } from "../Contracts.cjs";
|
|
2
|
+
import { Response } from "../core/Response.cjs";
|
|
3
|
+
import { ClassMiddleware, ControllerHandler } from "./basic.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 = RouteHandler | ControllerHandler;
|
|
5
22
|
type MiddlewareFunction = Koa.Middleware<any, any>;
|
|
6
23
|
type Middleware = MiddlewareFunction | ClassMiddleware<MiddlewareFunction>;
|
|
24
|
+
type KoaRouterApp = Router<any, any>;
|
|
7
25
|
//#endregion
|
|
8
|
-
export { Middleware };
|
|
26
|
+
export { Handler, HttpContext, KoaRouterApp, Middleware };
|
package/package.json
CHANGED