@h3ravel/router 1.13.2 → 1.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -10
- package/dist/index.d.mts +0 -245
- /package/dist/{index.d.cts → index.d.ts} +0 -0
- /package/dist/{index.mjs → index.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/router",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.5",
|
|
4
4
|
"description": "Route facade, decorators and controller system for H3ravel.",
|
|
5
5
|
"h3ravel": {
|
|
6
6
|
"providers": [
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
|
-
"main": "./dist/index.
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"module": "./dist/index.js",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./dist/index.d.ts",
|
|
18
17
|
"import": "./dist/index.js",
|
|
19
18
|
"require": "./dist/index.cjs"
|
|
20
|
-
}
|
|
19
|
+
},
|
|
20
|
+
"./*": "./*"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
@@ -42,16 +42,17 @@
|
|
|
42
42
|
"laravel"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@h3ravel/musket": "^0.3.
|
|
45
|
+
"@h3ravel/musket": "^0.3.9",
|
|
46
46
|
"h3": "2.0.1-rc.5",
|
|
47
47
|
"reflect-metadata": "^0.2.2",
|
|
48
|
-
"@h3ravel/
|
|
49
|
-
"@h3ravel/
|
|
50
|
-
"@h3ravel/support": "^0.15.
|
|
51
|
-
"@h3ravel/
|
|
52
|
-
"@h3ravel/
|
|
48
|
+
"@h3ravel/core": "^1.21.5",
|
|
49
|
+
"@h3ravel/database": "^11.4.10",
|
|
50
|
+
"@h3ravel/support": "^0.15.5",
|
|
51
|
+
"@h3ravel/shared": "^0.27.6",
|
|
52
|
+
"@h3ravel/http": "^11.7.5"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
+
"barrel": "barrelsby --directory src --delete --singleQuotes",
|
|
55
56
|
"build": "tsdown --config-loader unconfig",
|
|
56
57
|
"dev": "tsx watch src/index.ts",
|
|
57
58
|
"start": "node dist/index.js",
|
package/dist/index.d.mts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import { EventHandler, ExtractControllerMethods, HttpContext, IMiddleware, IRouter, RouteEventHandler, RouterEnd } from "@h3ravel/shared";
|
|
3
|
-
import { Command } from "@h3ravel/musket";
|
|
4
|
-
import { Application, ServiceProvider } from "@h3ravel/core";
|
|
5
|
-
import { H3, Middleware, MiddlewareOptions } from "h3";
|
|
6
|
-
import "reflect-metadata";
|
|
7
|
-
import { Model } from "@h3ravel/database";
|
|
8
|
-
|
|
9
|
-
//#region src/Commands/RouteListCommand.d.ts
|
|
10
|
-
declare class RouteListCommand extends Command {
|
|
11
|
-
/**
|
|
12
|
-
* The name and signature of the console command.
|
|
13
|
-
*
|
|
14
|
-
* @var string
|
|
15
|
-
*/
|
|
16
|
-
protected signature: string;
|
|
17
|
-
/**
|
|
18
|
-
* The console command description.
|
|
19
|
-
*
|
|
20
|
-
* @var string
|
|
21
|
-
*/
|
|
22
|
-
protected description: string;
|
|
23
|
-
/**
|
|
24
|
-
* Execute the console command.
|
|
25
|
-
*/
|
|
26
|
-
handle(this: any): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* List all registered routes.
|
|
29
|
-
*/
|
|
30
|
-
protected list(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Get the color
|
|
33
|
-
*
|
|
34
|
-
* @param method
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
private color;
|
|
38
|
-
/**
|
|
39
|
-
* Get the alternate method
|
|
40
|
-
*
|
|
41
|
-
* @param method
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
private pair;
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/Helpers.d.ts
|
|
48
|
-
declare class Helpers {
|
|
49
|
-
/**
|
|
50
|
-
* Extracts parameter names from a route path string.
|
|
51
|
-
*
|
|
52
|
-
* - Looks for segments prefixed with ":" (e.g. "/users/:id")
|
|
53
|
-
* - Captures only the param name (without the ":")
|
|
54
|
-
* - Returns all matches in order of appearance
|
|
55
|
-
*
|
|
56
|
-
* @param path - The route path string (e.g. "/groups/:group/users/:user")
|
|
57
|
-
* @returns An array of parameter names (e.g. ["group", "user"])
|
|
58
|
-
*/
|
|
59
|
-
static extractParams(path: string): string[];
|
|
60
|
-
/**
|
|
61
|
-
* Resolves route model binding for a given path, HTTP context, and model.
|
|
62
|
-
*
|
|
63
|
-
* - Extracts all route parameters from the given path
|
|
64
|
-
* - If a parameter matches the model name, it attempts to resolve the model binding
|
|
65
|
-
* using the provided value and binding field (defaults to "id" unless specified).
|
|
66
|
-
* - For non-matching parameters, it simply returns the key-value pair as is.
|
|
67
|
-
* - If no parameters are found, returns an empty object.
|
|
68
|
-
*
|
|
69
|
-
* @param path - The route path (e.g. "/groups/:group/users/:user")
|
|
70
|
-
* @param ctx - The HTTP context containing the request
|
|
71
|
-
* @param model - The model instance to resolve bindings against
|
|
72
|
-
* @returns A resolved model instance or an object containing param values
|
|
73
|
-
*/
|
|
74
|
-
static resolveRouteModelBinding(path: string, ctx: HttpContext, model: Model): Promise<any>;
|
|
75
|
-
}
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/Providers/AssetsServiceProvider.d.ts
|
|
78
|
-
/**
|
|
79
|
-
* Handles public assets loading
|
|
80
|
-
*
|
|
81
|
-
* Auto-Registered
|
|
82
|
-
*/
|
|
83
|
-
declare class AssetsServiceProvider extends ServiceProvider {
|
|
84
|
-
static priority: number;
|
|
85
|
-
register(): void;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/Providers/RouteServiceProvider.d.ts
|
|
89
|
-
/**
|
|
90
|
-
* Handles routing registration
|
|
91
|
-
*
|
|
92
|
-
* Load route files (web.ts, api.ts).
|
|
93
|
-
* Map controllers to routes.
|
|
94
|
-
* Register route-related middleware.
|
|
95
|
-
*
|
|
96
|
-
* Auto-Registered
|
|
97
|
-
*/
|
|
98
|
-
declare class RouteServiceProvider extends ServiceProvider {
|
|
99
|
-
static priority: number;
|
|
100
|
-
register(): void;
|
|
101
|
-
/**
|
|
102
|
-
* Load routes from src/routes
|
|
103
|
-
*/
|
|
104
|
-
boot(): Promise<void>;
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/Route.d.ts
|
|
108
|
-
declare class Router implements IRouter {
|
|
109
|
-
protected h3App: H3;
|
|
110
|
-
private app;
|
|
111
|
-
private routes;
|
|
112
|
-
private nameMap;
|
|
113
|
-
private groupPrefix;
|
|
114
|
-
private middlewareMap;
|
|
115
|
-
private groupMiddleware;
|
|
116
|
-
constructor(h3App: H3, app: Application);
|
|
117
|
-
/**
|
|
118
|
-
* Route Resolver
|
|
119
|
-
*
|
|
120
|
-
* @param handler
|
|
121
|
-
* @param middleware
|
|
122
|
-
* @returns
|
|
123
|
-
*/
|
|
124
|
-
private resolveHandler;
|
|
125
|
-
/**
|
|
126
|
-
* Add a route to the stack
|
|
127
|
-
*
|
|
128
|
-
* @param method
|
|
129
|
-
* @param path
|
|
130
|
-
* @param handler
|
|
131
|
-
* @param name
|
|
132
|
-
* @param middleware
|
|
133
|
-
*/
|
|
134
|
-
private addRoute;
|
|
135
|
-
/**
|
|
136
|
-
* Resolves a route handler definition into an executable EventHandler.
|
|
137
|
-
*
|
|
138
|
-
* A handler can be:
|
|
139
|
-
* - A function matching the EventHandler signature
|
|
140
|
-
* - A controller class (optionally decorated for IoC resolution)
|
|
141
|
-
*
|
|
142
|
-
* If it’s a controller class, this method will:
|
|
143
|
-
* - Instantiate it (via IoC or manually)
|
|
144
|
-
* - Call the specified method (defaults to `index`)
|
|
145
|
-
*
|
|
146
|
-
* @param handler Event handler function OR controller class
|
|
147
|
-
* @param methodName Method to invoke on the controller (defaults to 'index')
|
|
148
|
-
*/
|
|
149
|
-
private resolveControllerOrHandler;
|
|
150
|
-
/**
|
|
151
|
-
* Registers a route that responds to HTTP GET requests.
|
|
152
|
-
*
|
|
153
|
-
* @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
|
|
154
|
-
* @param definition Either:
|
|
155
|
-
* - An EventHandler function
|
|
156
|
-
* - A tuple: [ControllerClass, methodName]
|
|
157
|
-
* @param name Optional route name (for URL generation or referencing).
|
|
158
|
-
* @param middleware Optional array of middleware functions to execute before the handler.
|
|
159
|
-
*/
|
|
160
|
-
get<C extends new (...args: any) => any>(path: string, definition: RouteEventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
161
|
-
/**
|
|
162
|
-
* Registers a route that responds to HTTP POST requests.
|
|
163
|
-
*
|
|
164
|
-
* @param path The URL pattern to match (can include parameters, e.g., '/users').
|
|
165
|
-
* @param definition Either:
|
|
166
|
-
* - An EventHandler function
|
|
167
|
-
* - A tuple: [ControllerClass, methodName]
|
|
168
|
-
* @param name Optional route name (for URL generation or referencing).
|
|
169
|
-
* @param middleware Optional array of middleware functions to execute before the handler.
|
|
170
|
-
*/
|
|
171
|
-
post<C extends new (...args: any) => any>(path: string, definition: RouteEventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
172
|
-
/**
|
|
173
|
-
* Registers a route that responds to HTTP PUT requests.
|
|
174
|
-
*
|
|
175
|
-
* @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
|
|
176
|
-
* @param definition Either:
|
|
177
|
-
* - An EventHandler function
|
|
178
|
-
* - A tuple: [ControllerClass, methodName]
|
|
179
|
-
* @param name Optional route name (for URL generation or referencing).
|
|
180
|
-
* @param middleware Optional array of middleware functions to execute before the handler.
|
|
181
|
-
*/
|
|
182
|
-
put<C extends new (...args: any) => any>(path: string, definition: RouteEventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
183
|
-
/**
|
|
184
|
-
* Registers a route that responds to HTTP PATCH requests.
|
|
185
|
-
*
|
|
186
|
-
* @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
|
|
187
|
-
* @param definition Either:
|
|
188
|
-
* - An EventHandler function
|
|
189
|
-
* - A tuple: [ControllerClass, methodName]
|
|
190
|
-
* @param name Optional route name (for URL generation or referencing).
|
|
191
|
-
* @param middleware Optional array of middleware functions to execute before the handler.
|
|
192
|
-
*/
|
|
193
|
-
patch<C extends new (...args: any) => any>(path: string, definition: RouteEventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
194
|
-
/**
|
|
195
|
-
* Registers a route that responds to HTTP DELETE requests.
|
|
196
|
-
*
|
|
197
|
-
* @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
|
|
198
|
-
* @param definition Either:
|
|
199
|
-
* - An EventHandler function
|
|
200
|
-
* - A tuple: [ControllerClass, methodName]
|
|
201
|
-
* @param name Optional route name (for URL generation or referencing).
|
|
202
|
-
* @param middleware Optional array of middleware functions to execute before the handler.
|
|
203
|
-
*/
|
|
204
|
-
delete<C extends new (...args: any) => any>(path: string, definition: RouteEventHandler | [C, methodName: ExtractControllerMethods<InstanceType<C>>], name?: string, middleware?: IMiddleware[]): Omit<this, RouterEnd>;
|
|
205
|
-
/**
|
|
206
|
-
* API Resource support
|
|
207
|
-
*
|
|
208
|
-
* @param path
|
|
209
|
-
* @param controller
|
|
210
|
-
*/
|
|
211
|
-
apiResource<C extends new (...args: any) => any>(path: string, Controller: C, middleware?: IMiddleware[]): Omit<this, RouterEnd | 'name'>;
|
|
212
|
-
/**
|
|
213
|
-
* Named route URL generator
|
|
214
|
-
*
|
|
215
|
-
* @param name
|
|
216
|
-
* @param params
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
route(name: string, params?: Record<string, string>): string | undefined;
|
|
220
|
-
/**
|
|
221
|
-
* Grouping
|
|
222
|
-
*
|
|
223
|
-
* @param options
|
|
224
|
-
* @param callback
|
|
225
|
-
*/
|
|
226
|
-
group(options: {
|
|
227
|
-
prefix?: string;
|
|
228
|
-
middleware?: EventHandler[];
|
|
229
|
-
}, callback: (_e: this) => void): this;
|
|
230
|
-
/**
|
|
231
|
-
* Set the name of the current route
|
|
232
|
-
*
|
|
233
|
-
* @param name
|
|
234
|
-
*/
|
|
235
|
-
name(name: string): this;
|
|
236
|
-
/**
|
|
237
|
-
* Registers middleware for a specific path.
|
|
238
|
-
* @param path - The path to apply the middleware.
|
|
239
|
-
* @param handler - The middleware handler.
|
|
240
|
-
* @param opts - Optional middleware options.
|
|
241
|
-
*/
|
|
242
|
-
middleware(path: string | IMiddleware[] | Middleware, handler: Middleware | MiddlewareOptions, opts?: MiddlewareOptions): this;
|
|
243
|
-
}
|
|
244
|
-
//#endregion
|
|
245
|
-
export { AssetsServiceProvider, Helpers, RouteListCommand, RouteServiceProvider, Router };
|
|
File without changes
|
|
File without changes
|