clear-router 2.8.4 → 2.8.6
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/ResourceRoutes.cjs +1 -1
- package/dist/ResourceRoutes.mjs +1 -1
- package/dist/RouteGroup.d.cts +4 -4
- package/dist/RouteGroup.d.mts +4 -4
- package/dist/core/CoreRouter.cjs +2 -2
- package/dist/core/CoreRouter.d.cts +1 -1
- package/dist/core/CoreRouter.d.mts +1 -1
- package/dist/core/CoreRouter.mjs +2 -2
- package/dist/core/index.cjs +9 -0
- package/dist/core/index.mjs +2 -2
- package/dist/express/router.d.cts +14 -14
- package/dist/express/router.d.mts +14 -14
- package/dist/fastify/router.d.cts +14 -14
- package/dist/fastify/router.d.mts +14 -14
- package/dist/h3/router.d.cts +14 -14
- package/dist/h3/router.d.mts +14 -14
- package/dist/hono/router.d.cts +14 -14
- package/dist/hono/router.d.mts +14 -14
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/koa/router.d.cts +16 -16
- package/dist/koa/router.d.mts +16 -16
- package/dist/types/basic.cjs +0 -0
- package/dist/types/basic.d.cts +8 -5
- package/dist/types/basic.d.mts +9 -6
- package/dist/types/express.cjs +0 -0
- package/dist/types/express.d.cts +2 -2
- package/dist/types/express.d.mts +2 -2
- package/dist/types/fastify.cjs +0 -0
- package/dist/types/fastify.d.cts +2 -2
- package/dist/types/fastify.d.mts +2 -2
- package/dist/types/h3.cjs +0 -0
- package/dist/types/h3.d.cts +7 -5
- package/dist/types/h3.d.mts +7 -5
- package/dist/types/hono.cjs +0 -0
- package/dist/types/hono.d.cts +3 -2
- package/dist/types/hono.d.mts +3 -2
- package/dist/types/koa.cjs +0 -0
- package/dist/types/koa.d.cts +3 -2
- package/dist/types/koa.d.mts +3 -2
- package/package.json +25 -7
- package/dist/Route-tq-rge1g.d.mts +0 -136
- package/dist/types/index.d.mts +0 -1
package/dist/ResourceRoutes.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_ResourceRouteSelection = require('./ResourceRouteSelection.cjs');
|
|
2
1
|
const require_helpers = require('./core/helpers.cjs');
|
|
2
|
+
const require_ResourceRouteSelection = require('./ResourceRouteSelection.cjs');
|
|
3
3
|
require('./core/index.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/ResourceRoutes.ts
|
package/dist/ResourceRoutes.mjs
CHANGED
package/dist/RouteGroup.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Middleware } from "./types/express.cjs";
|
|
2
2
|
import { Middleware as Middleware$1 } from "./types/h3.cjs";
|
|
3
|
-
import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.cjs";
|
|
3
|
+
import { RouteGroupCondition, RouteGroupOptions, RouteGroupSource } from "./types/basic.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/RouteGroup.d.ts
|
|
6
6
|
/**
|
|
@@ -9,21 +9,21 @@ import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.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$1 | Middleware, H = any> implements PromiseLike<void> {
|
|
12
|
+
declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any, S extends RouteGroupSource = RouteGroupSource> implements PromiseLike<void> {
|
|
13
13
|
private readonly options;
|
|
14
14
|
private readonly checks;
|
|
15
15
|
private readonly conditions;
|
|
16
16
|
private readonly registration;
|
|
17
17
|
private readonly routes;
|
|
18
18
|
private readonly unfilteredSources;
|
|
19
|
-
constructor(options: RouteGroupOptions);
|
|
19
|
+
constructor(options: RouteGroupOptions<S>);
|
|
20
20
|
/**
|
|
21
21
|
* Returning a falsy value will stop route group registration
|
|
22
22
|
*
|
|
23
23
|
* @param condition
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
|
-
when(condition: RouteGroupCondition): this;
|
|
26
|
+
when(condition: RouteGroupCondition<S>): this;
|
|
27
27
|
/**
|
|
28
28
|
* Register one or more middleware that will be executed before every route in the group.
|
|
29
29
|
*
|
package/dist/RouteGroup.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Middleware } from "./types/express.mjs";
|
|
2
2
|
import { Middleware as Middleware$1 } from "./types/h3.mjs";
|
|
3
|
-
import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.mjs";
|
|
3
|
+
import { RouteGroupCondition, RouteGroupOptions, RouteGroupSource } from "./types/basic.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/RouteGroup.d.ts
|
|
6
6
|
/**
|
|
@@ -9,21 +9,21 @@ import { RouteGroupCondition, RouteGroupOptions } from "./types/basic.mjs";
|
|
|
9
9
|
* @author 3m1n3nc3
|
|
10
10
|
* @repository https://github.com/arkstack-tmp/clear-router
|
|
11
11
|
*/
|
|
12
|
-
declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any> implements PromiseLike<void> {
|
|
12
|
+
declare class RouteGroup<X = any, M = Middleware$1 | Middleware, H = any, S extends RouteGroupSource = RouteGroupSource> implements PromiseLike<void> {
|
|
13
13
|
private readonly options;
|
|
14
14
|
private readonly checks;
|
|
15
15
|
private readonly conditions;
|
|
16
16
|
private readonly registration;
|
|
17
17
|
private readonly routes;
|
|
18
18
|
private readonly unfilteredSources;
|
|
19
|
-
constructor(options: RouteGroupOptions);
|
|
19
|
+
constructor(options: RouteGroupOptions<S>);
|
|
20
20
|
/**
|
|
21
21
|
* Returning a falsy value will stop route group registration
|
|
22
22
|
*
|
|
23
23
|
* @param condition
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
|
-
when(condition: RouteGroupCondition): this;
|
|
26
|
+
when(condition: RouteGroupCondition<S>): this;
|
|
27
27
|
/**
|
|
28
28
|
* Register one or more middleware that will be executed before every route in the group.
|
|
29
29
|
*
|
package/dist/core/CoreRouter.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
const require_Route = require('../Route.cjs');
|
|
2
|
+
const require_RouteGroup = require('../RouteGroup.cjs');
|
|
1
3
|
const require_Request = require('./Request.cjs');
|
|
2
4
|
const require_Response = require('./Response.cjs');
|
|
3
5
|
const require_bindings = require('./bindings.cjs');
|
|
4
6
|
const require_ResourceRoutes = require('../ResourceRoutes.cjs');
|
|
5
|
-
const require_Route = require('../Route.cjs');
|
|
6
|
-
const require_RouteGroup = require('../RouteGroup.cjs');
|
|
7
7
|
let node_async_hooks = require("node:async_hooks");
|
|
8
8
|
let node_module = require("node:module");
|
|
9
9
|
|
|
@@ -214,7 +214,7 @@ declare abstract class CoreRouter {
|
|
|
214
214
|
* @param callback
|
|
215
215
|
* @param middlewares
|
|
216
216
|
*/
|
|
217
|
-
static group(prefix: string, source:
|
|
217
|
+
static group<S extends RouteGroupSource>(prefix: string, source: S, middlewares?: any[]): RouteGroup<any, any, any, S>;
|
|
218
218
|
/**
|
|
219
219
|
* Adds global middlewares to the router, which will be applied to all routes.
|
|
220
220
|
*
|
|
@@ -214,7 +214,7 @@ declare abstract class CoreRouter {
|
|
|
214
214
|
* @param callback
|
|
215
215
|
* @param middlewares
|
|
216
216
|
*/
|
|
217
|
-
static group(prefix: string, source:
|
|
217
|
+
static group<S extends RouteGroupSource>(prefix: string, source: S, middlewares?: any[]): RouteGroup<any, any, any, S>;
|
|
218
218
|
/**
|
|
219
219
|
* Adds global middlewares to the router, which will be applied to all routes.
|
|
220
220
|
*
|
package/dist/core/CoreRouter.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Route } from "../Route.mjs";
|
|
2
|
+
import { RouteGroup } from "../RouteGroup.mjs";
|
|
1
3
|
import { Request } from "./Request.mjs";
|
|
2
4
|
import { Response } from "./Response.mjs";
|
|
3
5
|
import { Container, getBindingMetadataFromTargets, getDesignParamTypes, getStandardMetadata, isClass } from "./bindings.mjs";
|
|
4
6
|
import { ResourceRoutes } from "../ResourceRoutes.mjs";
|
|
5
|
-
import { Route } from "../Route.mjs";
|
|
6
|
-
import { RouteGroup } from "../RouteGroup.mjs";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
9
|
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_helpers = require('./helpers.cjs');
|
|
2
3
|
const require_RouteGroup = require('../RouteGroup.cjs');
|
|
3
4
|
const require_Request = require('./Request.cjs');
|
|
4
5
|
const require_Response = require('./Response.cjs');
|
|
5
6
|
const require_plugins = require('./plugins.cjs');
|
|
6
7
|
const require_CoreRouter = require('./CoreRouter.cjs');
|
|
8
|
+
|
|
9
|
+
exports.CoreRouter = require_CoreRouter.CoreRouter;
|
|
10
|
+
exports.Request = require_Request.Request;
|
|
11
|
+
exports.Response = require_Response.Response;
|
|
12
|
+
exports.RouteGroup = require_RouteGroup.RouteGroup;
|
|
13
|
+
exports.definePlugin = require_plugins.definePlugin;
|
|
14
|
+
exports.importFile = require_helpers.importFile;
|
|
15
|
+
exports.wrap = require_helpers.wrap;
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { importFile, wrap } from "./helpers.mjs";
|
|
2
|
+
import { RouteGroup } from "../RouteGroup.mjs";
|
|
1
3
|
import { Request } from "./Request.mjs";
|
|
2
4
|
import { Response } from "./Response.mjs";
|
|
3
5
|
import { definePlugin } from "./plugins.mjs";
|
|
4
|
-
import { importFile, wrap } from "./helpers.mjs";
|
|
5
|
-
import { RouteGroup } from "../RouteGroup.mjs";
|
|
6
6
|
import { CoreRouter } from "./CoreRouter.mjs";
|
|
7
7
|
|
|
8
8
|
export { CoreRouter, Request, Response, RouteGroup, definePlugin, importFile, wrap };
|
|
@@ -26,7 +26,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
26
26
|
* @param handler
|
|
27
27
|
* @param middlewares
|
|
28
28
|
*/
|
|
29
|
-
static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler
|
|
29
|
+
static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
30
30
|
/**
|
|
31
31
|
* Define a resourceful API controller with standard CRUD routes
|
|
32
32
|
*
|
|
@@ -46,7 +46,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
46
46
|
* @param handler
|
|
47
47
|
* @param middlewares
|
|
48
48
|
*/
|
|
49
|
-
static get(path: string, handler: Handler
|
|
49
|
+
static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
50
50
|
/**
|
|
51
51
|
* Adds a new POST route to the router.
|
|
52
52
|
*
|
|
@@ -54,7 +54,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
54
54
|
* @param handler
|
|
55
55
|
* @param middlewares
|
|
56
56
|
*/
|
|
57
|
-
static post(path: string, handler: Handler
|
|
57
|
+
static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
58
58
|
/**
|
|
59
59
|
* Adds a new PUT route to the router.
|
|
60
60
|
*
|
|
@@ -62,7 +62,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
62
62
|
* @param handler
|
|
63
63
|
* @param middlewares
|
|
64
64
|
*/
|
|
65
|
-
static put(path: string, handler: Handler
|
|
65
|
+
static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
66
66
|
/**
|
|
67
67
|
* Adds a new DELETE route to the router.
|
|
68
68
|
*
|
|
@@ -70,7 +70,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
70
70
|
* @param handler
|
|
71
71
|
* @param middlewares
|
|
72
72
|
*/
|
|
73
|
-
static delete(path: string, handler: Handler
|
|
73
|
+
static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
74
74
|
/**
|
|
75
75
|
* Adds a new PATCH route to the router.
|
|
76
76
|
*
|
|
@@ -78,7 +78,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
78
78
|
* @param handler
|
|
79
79
|
* @param middlewares
|
|
80
80
|
*/
|
|
81
|
-
static patch(path: string, handler: Handler
|
|
81
|
+
static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
82
82
|
/**
|
|
83
83
|
* Adds a new OPTIONS route to the router.
|
|
84
84
|
*
|
|
@@ -86,7 +86,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
86
86
|
* @param handler
|
|
87
87
|
* @param middlewares
|
|
88
88
|
*/
|
|
89
|
-
static options(path: string, handler: Handler
|
|
89
|
+
static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
90
90
|
/**
|
|
91
91
|
* Adds a new HEAD route to the router.
|
|
92
92
|
*
|
|
@@ -94,7 +94,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
94
94
|
* @param handler
|
|
95
95
|
* @param middlewares
|
|
96
96
|
*/
|
|
97
|
-
static head(path: string, handler: Handler
|
|
97
|
+
static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
98
98
|
/**
|
|
99
99
|
* Defines a group of routes with a common prefix.
|
|
100
100
|
*
|
|
@@ -102,7 +102,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
102
102
|
* @param callback
|
|
103
103
|
* @param middlewares
|
|
104
104
|
*/
|
|
105
|
-
static group(prefix: string, source:
|
|
105
|
+
static group<T = any, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
|
|
106
106
|
/**
|
|
107
107
|
* Adds global middlewares to the router, which will be applied to all routes.
|
|
108
108
|
*
|
|
@@ -115,11 +115,11 @@ declare class Router$1 extends CoreRouter {
|
|
|
115
115
|
*
|
|
116
116
|
* @param type
|
|
117
117
|
*/
|
|
118
|
-
static allRoutes(): Array<Route<HttpContext, Middleware, Handler
|
|
119
|
-
static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler
|
|
120
|
-
static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler
|
|
121
|
-
static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler
|
|
122
|
-
static route(name: string): Route<HttpContext, Middleware, Handler
|
|
118
|
+
static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
|
|
119
|
+
static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
120
|
+
static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
|
|
121
|
+
static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
122
|
+
static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
|
|
123
123
|
/**
|
|
124
124
|
* Applies the registered routes to the given Express router instance, setting up the necessary
|
|
125
125
|
* handlers and middlewares for each route.
|
|
@@ -26,7 +26,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
26
26
|
* @param handler
|
|
27
27
|
* @param middlewares
|
|
28
28
|
*/
|
|
29
|
-
static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler
|
|
29
|
+
static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
30
30
|
/**
|
|
31
31
|
* Define a resourceful API controller with standard CRUD routes
|
|
32
32
|
*
|
|
@@ -46,7 +46,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
46
46
|
* @param handler
|
|
47
47
|
* @param middlewares
|
|
48
48
|
*/
|
|
49
|
-
static get(path: string, handler: Handler
|
|
49
|
+
static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
50
50
|
/**
|
|
51
51
|
* Adds a new POST route to the router.
|
|
52
52
|
*
|
|
@@ -54,7 +54,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
54
54
|
* @param handler
|
|
55
55
|
* @param middlewares
|
|
56
56
|
*/
|
|
57
|
-
static post(path: string, handler: Handler
|
|
57
|
+
static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
58
58
|
/**
|
|
59
59
|
* Adds a new PUT route to the router.
|
|
60
60
|
*
|
|
@@ -62,7 +62,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
62
62
|
* @param handler
|
|
63
63
|
* @param middlewares
|
|
64
64
|
*/
|
|
65
|
-
static put(path: string, handler: Handler
|
|
65
|
+
static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
66
66
|
/**
|
|
67
67
|
* Adds a new DELETE route to the router.
|
|
68
68
|
*
|
|
@@ -70,7 +70,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
70
70
|
* @param handler
|
|
71
71
|
* @param middlewares
|
|
72
72
|
*/
|
|
73
|
-
static delete(path: string, handler: Handler
|
|
73
|
+
static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
74
74
|
/**
|
|
75
75
|
* Adds a new PATCH route to the router.
|
|
76
76
|
*
|
|
@@ -78,7 +78,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
78
78
|
* @param handler
|
|
79
79
|
* @param middlewares
|
|
80
80
|
*/
|
|
81
|
-
static patch(path: string, handler: Handler
|
|
81
|
+
static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
82
82
|
/**
|
|
83
83
|
* Adds a new OPTIONS route to the router.
|
|
84
84
|
*
|
|
@@ -86,7 +86,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
86
86
|
* @param handler
|
|
87
87
|
* @param middlewares
|
|
88
88
|
*/
|
|
89
|
-
static options(path: string, handler: Handler
|
|
89
|
+
static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
90
90
|
/**
|
|
91
91
|
* Adds a new HEAD route to the router.
|
|
92
92
|
*
|
|
@@ -94,7 +94,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
94
94
|
* @param handler
|
|
95
95
|
* @param middlewares
|
|
96
96
|
*/
|
|
97
|
-
static head(path: string, handler: Handler
|
|
97
|
+
static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
98
98
|
/**
|
|
99
99
|
* Defines a group of routes with a common prefix.
|
|
100
100
|
*
|
|
@@ -102,7 +102,7 @@ declare class Router$1 extends CoreRouter {
|
|
|
102
102
|
* @param callback
|
|
103
103
|
* @param middlewares
|
|
104
104
|
*/
|
|
105
|
-
static group(prefix: string, source:
|
|
105
|
+
static group<T = any, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
|
|
106
106
|
/**
|
|
107
107
|
* Adds global middlewares to the router, which will be applied to all routes.
|
|
108
108
|
*
|
|
@@ -115,11 +115,11 @@ declare class Router$1 extends CoreRouter {
|
|
|
115
115
|
*
|
|
116
116
|
* @param type
|
|
117
117
|
*/
|
|
118
|
-
static allRoutes(): Array<Route<HttpContext, Middleware, Handler
|
|
119
|
-
static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler
|
|
120
|
-
static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler
|
|
121
|
-
static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler
|
|
122
|
-
static route(name: string): Route<HttpContext, Middleware, Handler
|
|
118
|
+
static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
|
|
119
|
+
static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
120
|
+
static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
|
|
121
|
+
static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
122
|
+
static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
|
|
123
123
|
/**
|
|
124
124
|
* Applies the registered routes to the given Express router instance, setting up the necessary
|
|
125
125
|
* handlers and middlewares for each route.
|
|
@@ -24,7 +24,7 @@ declare class Router extends CoreRouter {
|
|
|
24
24
|
* @param handler Route handler function
|
|
25
25
|
* @param middlewares Optional middlewares for the route
|
|
26
26
|
*/
|
|
27
|
-
static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler
|
|
27
|
+
static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
28
28
|
/**
|
|
29
29
|
* Define a resourceful API controller with standard CRUD routes
|
|
30
30
|
*
|
|
@@ -44,7 +44,7 @@ declare class Router extends CoreRouter {
|
|
|
44
44
|
* @param handler
|
|
45
45
|
* @param middlewares
|
|
46
46
|
*/
|
|
47
|
-
static get(path: string, handler: Handler
|
|
47
|
+
static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
48
48
|
/**
|
|
49
49
|
* Define a POST route
|
|
50
50
|
*
|
|
@@ -52,7 +52,7 @@ declare class Router extends CoreRouter {
|
|
|
52
52
|
* @param handler
|
|
53
53
|
* @param middlewares
|
|
54
54
|
*/
|
|
55
|
-
static post(path: string, handler: Handler
|
|
55
|
+
static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
56
56
|
/**
|
|
57
57
|
* Define a PUT route
|
|
58
58
|
*
|
|
@@ -60,7 +60,7 @@ declare class Router extends CoreRouter {
|
|
|
60
60
|
* @param handler
|
|
61
61
|
* @param middlewares
|
|
62
62
|
*/
|
|
63
|
-
static put(path: string, handler: Handler
|
|
63
|
+
static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
64
64
|
/**
|
|
65
65
|
* Define a DELETE route
|
|
66
66
|
*
|
|
@@ -68,7 +68,7 @@ declare class Router extends CoreRouter {
|
|
|
68
68
|
* @param handler
|
|
69
69
|
* @param middlewares
|
|
70
70
|
*/
|
|
71
|
-
static delete(path: string, handler: Handler
|
|
71
|
+
static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
72
72
|
/**
|
|
73
73
|
* Define a PATCH route
|
|
74
74
|
*
|
|
@@ -76,7 +76,7 @@ declare class Router extends CoreRouter {
|
|
|
76
76
|
* @param handler
|
|
77
77
|
* @param middlewares
|
|
78
78
|
*/
|
|
79
|
-
static patch(path: string, handler: Handler
|
|
79
|
+
static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
80
80
|
/**
|
|
81
81
|
* Define an OPTIONS route
|
|
82
82
|
*
|
|
@@ -84,7 +84,7 @@ declare class Router extends CoreRouter {
|
|
|
84
84
|
* @param handler
|
|
85
85
|
* @param middlewares
|
|
86
86
|
*/
|
|
87
|
-
static options(path: string, handler: Handler
|
|
87
|
+
static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
88
88
|
/**
|
|
89
89
|
* Define a HEAD route
|
|
90
90
|
*
|
|
@@ -92,7 +92,7 @@ declare class Router extends CoreRouter {
|
|
|
92
92
|
* @param handler
|
|
93
93
|
* @param middlewares
|
|
94
94
|
*/
|
|
95
|
-
static head(path: string, handler: Handler
|
|
95
|
+
static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
96
96
|
/**
|
|
97
97
|
* Define a group of routes with a common prefix and optional middlewares
|
|
98
98
|
*
|
|
@@ -100,7 +100,7 @@ declare class Router extends CoreRouter {
|
|
|
100
100
|
* @param callback
|
|
101
101
|
* @param middlewares
|
|
102
102
|
*/
|
|
103
|
-
static group(prefix: string, source:
|
|
103
|
+
static group<T = any, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
|
|
104
104
|
/**
|
|
105
105
|
* Apply middlewares to a group of routes defined within the callback
|
|
106
106
|
*
|
|
@@ -108,17 +108,17 @@ declare class Router extends CoreRouter {
|
|
|
108
108
|
* @param callback
|
|
109
109
|
*/
|
|
110
110
|
static middleware(middlewares: Middleware[], callback: () => void): void;
|
|
111
|
-
static allRoutes(): Array<Route<HttpContext, Middleware, Handler
|
|
111
|
+
static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
|
|
112
112
|
/**
|
|
113
113
|
* @param type - 'path' to get routes organized by path
|
|
114
114
|
*/
|
|
115
|
-
static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler
|
|
115
|
+
static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
116
116
|
/**
|
|
117
117
|
* @param type - 'method' to get routes organized by method
|
|
118
118
|
*/
|
|
119
|
-
static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler
|
|
120
|
-
static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler
|
|
121
|
-
static route(name: string): Route<HttpContext, Middleware, Handler
|
|
119
|
+
static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
|
|
120
|
+
static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
121
|
+
static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
|
|
122
122
|
/**
|
|
123
123
|
* Apply the defined routes to a Fastify application instance
|
|
124
124
|
*
|
|
@@ -24,7 +24,7 @@ declare class Router extends CoreRouter {
|
|
|
24
24
|
* @param handler Route handler function
|
|
25
25
|
* @param middlewares Optional middlewares for the route
|
|
26
26
|
*/
|
|
27
|
-
static add(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler
|
|
27
|
+
static add<T = any>(methods: HttpMethod | HttpMethod[], path: string, handler: Handler, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
28
28
|
/**
|
|
29
29
|
* Define a resourceful API controller with standard CRUD routes
|
|
30
30
|
*
|
|
@@ -44,7 +44,7 @@ declare class Router extends CoreRouter {
|
|
|
44
44
|
* @param handler
|
|
45
45
|
* @param middlewares
|
|
46
46
|
*/
|
|
47
|
-
static get(path: string, handler: Handler
|
|
47
|
+
static get<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
48
48
|
/**
|
|
49
49
|
* Define a POST route
|
|
50
50
|
*
|
|
@@ -52,7 +52,7 @@ declare class Router extends CoreRouter {
|
|
|
52
52
|
* @param handler
|
|
53
53
|
* @param middlewares
|
|
54
54
|
*/
|
|
55
|
-
static post(path: string, handler: Handler
|
|
55
|
+
static post<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
56
56
|
/**
|
|
57
57
|
* Define a PUT route
|
|
58
58
|
*
|
|
@@ -60,7 +60,7 @@ declare class Router extends CoreRouter {
|
|
|
60
60
|
* @param handler
|
|
61
61
|
* @param middlewares
|
|
62
62
|
*/
|
|
63
|
-
static put(path: string, handler: Handler
|
|
63
|
+
static put<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
64
64
|
/**
|
|
65
65
|
* Define a DELETE route
|
|
66
66
|
*
|
|
@@ -68,7 +68,7 @@ declare class Router extends CoreRouter {
|
|
|
68
68
|
* @param handler
|
|
69
69
|
* @param middlewares
|
|
70
70
|
*/
|
|
71
|
-
static delete(path: string, handler: Handler
|
|
71
|
+
static delete<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
72
72
|
/**
|
|
73
73
|
* Define a PATCH route
|
|
74
74
|
*
|
|
@@ -76,7 +76,7 @@ declare class Router extends CoreRouter {
|
|
|
76
76
|
* @param handler
|
|
77
77
|
* @param middlewares
|
|
78
78
|
*/
|
|
79
|
-
static patch(path: string, handler: Handler
|
|
79
|
+
static patch<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
80
80
|
/**
|
|
81
81
|
* Define an OPTIONS route
|
|
82
82
|
*
|
|
@@ -84,7 +84,7 @@ declare class Router extends CoreRouter {
|
|
|
84
84
|
* @param handler
|
|
85
85
|
* @param middlewares
|
|
86
86
|
*/
|
|
87
|
-
static options(path: string, handler: Handler
|
|
87
|
+
static options<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
88
88
|
/**
|
|
89
89
|
* Define a HEAD route
|
|
90
90
|
*
|
|
@@ -92,7 +92,7 @@ declare class Router extends CoreRouter {
|
|
|
92
92
|
* @param handler
|
|
93
93
|
* @param middlewares
|
|
94
94
|
*/
|
|
95
|
-
static head(path: string, handler: Handler
|
|
95
|
+
static head<T = any>(path: string, handler: Handler<T>, middlewares?: Middleware[] | Middleware): Route<HttpContext, Middleware, Handler<T>>;
|
|
96
96
|
/**
|
|
97
97
|
* Define a group of routes with a common prefix and optional middlewares
|
|
98
98
|
*
|
|
@@ -100,7 +100,7 @@ declare class Router extends CoreRouter {
|
|
|
100
100
|
* @param callback
|
|
101
101
|
* @param middlewares
|
|
102
102
|
*/
|
|
103
|
-
static group(prefix: string, source:
|
|
103
|
+
static group<T = any, S extends RouteGroupSource = RouteGroupSource>(prefix: string, source: S, middlewares?: Middleware[]): RouteGroup<HttpContext, Middleware, Handler<T>, S>;
|
|
104
104
|
/**
|
|
105
105
|
* Apply middlewares to a group of routes defined within the callback
|
|
106
106
|
*
|
|
@@ -108,17 +108,17 @@ declare class Router extends CoreRouter {
|
|
|
108
108
|
* @param callback
|
|
109
109
|
*/
|
|
110
110
|
static middleware(middlewares: Middleware[], callback: () => void): void;
|
|
111
|
-
static allRoutes(): Array<Route<HttpContext, Middleware, Handler
|
|
111
|
+
static allRoutes<T = any>(): Array<Route<HttpContext, Middleware, Handler<T>>>;
|
|
112
112
|
/**
|
|
113
113
|
* @param type - 'path' to get routes organized by path
|
|
114
114
|
*/
|
|
115
|
-
static allRoutes(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler
|
|
115
|
+
static allRoutes<T = any>(type: 'path'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
116
116
|
/**
|
|
117
117
|
* @param type - 'method' to get routes organized by method
|
|
118
118
|
*/
|
|
119
|
-
static allRoutes(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler
|
|
120
|
-
static allRoutes(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler
|
|
121
|
-
static route(name: string): Route<HttpContext, Middleware, Handler
|
|
119
|
+
static allRoutes<T = any>(type: 'method'): { [method in Uppercase<HttpMethod>]?: Array<Route<HttpContext, Middleware, Handler<T>>> };
|
|
120
|
+
static allRoutes<T = any>(type: 'name'): Record<string, Route<HttpContext, Middleware, Handler<T>>>;
|
|
121
|
+
static route<T = any>(name: string): Route<HttpContext, Middleware, Handler<T>> | undefined;
|
|
122
122
|
/**
|
|
123
123
|
* Apply the defined routes to a Fastify application instance
|
|
124
124
|
*
|