@h3ravel/router 1.7.5 → 1.8.0

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/index.js CHANGED
@@ -1,10 +1,1221 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // ../../node_modules/reflect-metadata/Reflect.js
29
+ var require_Reflect = __commonJS({
30
+ "../../node_modules/reflect-metadata/Reflect.js"() {
31
+ "use strict";
32
+ var Reflect2;
33
+ (function(Reflect3) {
34
+ (function(factory) {
35
+ var root = typeof globalThis === "object" ? globalThis : typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
36
+ var exporter = makeExporter(Reflect3);
37
+ if (typeof root.Reflect !== "undefined") {
38
+ exporter = makeExporter(root.Reflect, exporter);
39
+ }
40
+ factory(exporter, root);
41
+ if (typeof root.Reflect === "undefined") {
42
+ root.Reflect = Reflect3;
43
+ }
44
+ function makeExporter(target, previous) {
45
+ return function(key, value) {
46
+ Object.defineProperty(target, key, {
47
+ configurable: true,
48
+ writable: true,
49
+ value
50
+ });
51
+ if (previous)
52
+ previous(key, value);
53
+ };
54
+ }
55
+ __name(makeExporter, "makeExporter");
56
+ function functionThis() {
57
+ try {
58
+ return Function("return this;")();
59
+ } catch (_) {
60
+ }
61
+ }
62
+ __name(functionThis, "functionThis");
63
+ function indirectEvalThis() {
64
+ try {
65
+ return (0, eval)("(function() { return this; })()");
66
+ } catch (_) {
67
+ }
68
+ }
69
+ __name(indirectEvalThis, "indirectEvalThis");
70
+ function sloppyModeThis() {
71
+ return functionThis() || indirectEvalThis();
72
+ }
73
+ __name(sloppyModeThis, "sloppyModeThis");
74
+ })(function(exporter, root) {
75
+ var hasOwn = Object.prototype.hasOwnProperty;
76
+ var supportsSymbol = typeof Symbol === "function";
77
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
78
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
79
+ var supportsCreate = typeof Object.create === "function";
80
+ var supportsProto = {
81
+ __proto__: []
82
+ } instanceof Array;
83
+ var downLevel = !supportsCreate && !supportsProto;
84
+ var HashMap = {
85
+ // create an object in dictionary mode (a.k.a. "slow" mode in v8)
86
+ create: supportsCreate ? function() {
87
+ return MakeDictionary(/* @__PURE__ */ Object.create(null));
88
+ } : supportsProto ? function() {
89
+ return MakeDictionary({
90
+ __proto__: null
91
+ });
92
+ } : function() {
93
+ return MakeDictionary({});
94
+ },
95
+ has: downLevel ? function(map, key) {
96
+ return hasOwn.call(map, key);
97
+ } : function(map, key) {
98
+ return key in map;
99
+ },
100
+ get: downLevel ? function(map, key) {
101
+ return hasOwn.call(map, key) ? map[key] : void 0;
102
+ } : function(map, key) {
103
+ return map[key];
104
+ }
105
+ };
106
+ var functionPrototype = Object.getPrototypeOf(Function);
107
+ var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
108
+ var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
109
+ var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
110
+ var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : void 0;
111
+ var metadataRegistry = GetOrCreateMetadataRegistry();
112
+ var metadataProvider = CreateMetadataProvider(metadataRegistry);
113
+ function decorate(decorators, target, propertyKey, attributes) {
114
+ if (!IsUndefined(propertyKey)) {
115
+ if (!IsArray(decorators))
116
+ throw new TypeError();
117
+ if (!IsObject(target))
118
+ throw new TypeError();
119
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
120
+ throw new TypeError();
121
+ if (IsNull(attributes))
122
+ attributes = void 0;
123
+ propertyKey = ToPropertyKey(propertyKey);
124
+ return DecorateProperty(decorators, target, propertyKey, attributes);
125
+ } else {
126
+ if (!IsArray(decorators))
127
+ throw new TypeError();
128
+ if (!IsConstructor(target))
129
+ throw new TypeError();
130
+ return DecorateConstructor(decorators, target);
131
+ }
132
+ }
133
+ __name(decorate, "decorate");
134
+ exporter("decorate", decorate);
135
+ function metadata(metadataKey, metadataValue) {
136
+ function decorator(target, propertyKey) {
137
+ if (!IsObject(target))
138
+ throw new TypeError();
139
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
140
+ throw new TypeError();
141
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
142
+ }
143
+ __name(decorator, "decorator");
144
+ return decorator;
145
+ }
146
+ __name(metadata, "metadata");
147
+ exporter("metadata", metadata);
148
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
149
+ if (!IsObject(target))
150
+ throw new TypeError();
151
+ if (!IsUndefined(propertyKey))
152
+ propertyKey = ToPropertyKey(propertyKey);
153
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
154
+ }
155
+ __name(defineMetadata, "defineMetadata");
156
+ exporter("defineMetadata", defineMetadata);
157
+ function hasMetadata(metadataKey, target, propertyKey) {
158
+ if (!IsObject(target))
159
+ throw new TypeError();
160
+ if (!IsUndefined(propertyKey))
161
+ propertyKey = ToPropertyKey(propertyKey);
162
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
163
+ }
164
+ __name(hasMetadata, "hasMetadata");
165
+ exporter("hasMetadata", hasMetadata);
166
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
167
+ if (!IsObject(target))
168
+ throw new TypeError();
169
+ if (!IsUndefined(propertyKey))
170
+ propertyKey = ToPropertyKey(propertyKey);
171
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
172
+ }
173
+ __name(hasOwnMetadata, "hasOwnMetadata");
174
+ exporter("hasOwnMetadata", hasOwnMetadata);
175
+ function getMetadata(metadataKey, target, propertyKey) {
176
+ if (!IsObject(target))
177
+ throw new TypeError();
178
+ if (!IsUndefined(propertyKey))
179
+ propertyKey = ToPropertyKey(propertyKey);
180
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
181
+ }
182
+ __name(getMetadata, "getMetadata");
183
+ exporter("getMetadata", getMetadata);
184
+ function getOwnMetadata(metadataKey, target, propertyKey) {
185
+ if (!IsObject(target))
186
+ throw new TypeError();
187
+ if (!IsUndefined(propertyKey))
188
+ propertyKey = ToPropertyKey(propertyKey);
189
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
190
+ }
191
+ __name(getOwnMetadata, "getOwnMetadata");
192
+ exporter("getOwnMetadata", getOwnMetadata);
193
+ function getMetadataKeys(target, propertyKey) {
194
+ if (!IsObject(target))
195
+ throw new TypeError();
196
+ if (!IsUndefined(propertyKey))
197
+ propertyKey = ToPropertyKey(propertyKey);
198
+ return OrdinaryMetadataKeys(target, propertyKey);
199
+ }
200
+ __name(getMetadataKeys, "getMetadataKeys");
201
+ exporter("getMetadataKeys", getMetadataKeys);
202
+ function getOwnMetadataKeys(target, propertyKey) {
203
+ if (!IsObject(target))
204
+ throw new TypeError();
205
+ if (!IsUndefined(propertyKey))
206
+ propertyKey = ToPropertyKey(propertyKey);
207
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
208
+ }
209
+ __name(getOwnMetadataKeys, "getOwnMetadataKeys");
210
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
211
+ function deleteMetadata(metadataKey, target, propertyKey) {
212
+ if (!IsObject(target))
213
+ throw new TypeError();
214
+ if (!IsUndefined(propertyKey))
215
+ propertyKey = ToPropertyKey(propertyKey);
216
+ if (!IsObject(target))
217
+ throw new TypeError();
218
+ if (!IsUndefined(propertyKey))
219
+ propertyKey = ToPropertyKey(propertyKey);
220
+ var provider = GetMetadataProvider(
221
+ target,
222
+ propertyKey,
223
+ /*Create*/
224
+ false
225
+ );
226
+ if (IsUndefined(provider))
227
+ return false;
228
+ return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
229
+ }
230
+ __name(deleteMetadata, "deleteMetadata");
231
+ exporter("deleteMetadata", deleteMetadata);
232
+ function DecorateConstructor(decorators, target) {
233
+ for (var i = decorators.length - 1; i >= 0; --i) {
234
+ var decorator = decorators[i];
235
+ var decorated = decorator(target);
236
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
237
+ if (!IsConstructor(decorated))
238
+ throw new TypeError();
239
+ target = decorated;
240
+ }
241
+ }
242
+ return target;
243
+ }
244
+ __name(DecorateConstructor, "DecorateConstructor");
245
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
246
+ for (var i = decorators.length - 1; i >= 0; --i) {
247
+ var decorator = decorators[i];
248
+ var decorated = decorator(target, propertyKey, descriptor);
249
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
250
+ if (!IsObject(decorated))
251
+ throw new TypeError();
252
+ descriptor = decorated;
253
+ }
254
+ }
255
+ return descriptor;
256
+ }
257
+ __name(DecorateProperty, "DecorateProperty");
258
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
259
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
260
+ if (hasOwn2)
261
+ return true;
262
+ var parent = OrdinaryGetPrototypeOf(O);
263
+ if (!IsNull(parent))
264
+ return OrdinaryHasMetadata(MetadataKey, parent, P);
265
+ return false;
266
+ }
267
+ __name(OrdinaryHasMetadata, "OrdinaryHasMetadata");
268
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
269
+ var provider = GetMetadataProvider(
270
+ O,
271
+ P,
272
+ /*Create*/
273
+ false
274
+ );
275
+ if (IsUndefined(provider))
276
+ return false;
277
+ return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
278
+ }
279
+ __name(OrdinaryHasOwnMetadata, "OrdinaryHasOwnMetadata");
280
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
281
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
282
+ if (hasOwn2)
283
+ return OrdinaryGetOwnMetadata(MetadataKey, O, P);
284
+ var parent = OrdinaryGetPrototypeOf(O);
285
+ if (!IsNull(parent))
286
+ return OrdinaryGetMetadata(MetadataKey, parent, P);
287
+ return void 0;
288
+ }
289
+ __name(OrdinaryGetMetadata, "OrdinaryGetMetadata");
290
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
291
+ var provider = GetMetadataProvider(
292
+ O,
293
+ P,
294
+ /*Create*/
295
+ false
296
+ );
297
+ if (IsUndefined(provider))
298
+ return;
299
+ return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
300
+ }
301
+ __name(OrdinaryGetOwnMetadata, "OrdinaryGetOwnMetadata");
302
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
303
+ var provider = GetMetadataProvider(
304
+ O,
305
+ P,
306
+ /*Create*/
307
+ true
308
+ );
309
+ provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
310
+ }
311
+ __name(OrdinaryDefineOwnMetadata, "OrdinaryDefineOwnMetadata");
312
+ function OrdinaryMetadataKeys(O, P) {
313
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
314
+ var parent = OrdinaryGetPrototypeOf(O);
315
+ if (parent === null)
316
+ return ownKeys;
317
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
318
+ if (parentKeys.length <= 0)
319
+ return ownKeys;
320
+ if (ownKeys.length <= 0)
321
+ return parentKeys;
322
+ var set = new _Set();
323
+ var keys = [];
324
+ for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
325
+ var key = ownKeys_1[_i];
326
+ var hasKey = set.has(key);
327
+ if (!hasKey) {
328
+ set.add(key);
329
+ keys.push(key);
330
+ }
331
+ }
332
+ for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
333
+ var key = parentKeys_1[_a];
334
+ var hasKey = set.has(key);
335
+ if (!hasKey) {
336
+ set.add(key);
337
+ keys.push(key);
338
+ }
339
+ }
340
+ return keys;
341
+ }
342
+ __name(OrdinaryMetadataKeys, "OrdinaryMetadataKeys");
343
+ function OrdinaryOwnMetadataKeys(O, P) {
344
+ var provider = GetMetadataProvider(
345
+ O,
346
+ P,
347
+ /*create*/
348
+ false
349
+ );
350
+ if (!provider) {
351
+ return [];
352
+ }
353
+ return provider.OrdinaryOwnMetadataKeys(O, P);
354
+ }
355
+ __name(OrdinaryOwnMetadataKeys, "OrdinaryOwnMetadataKeys");
356
+ function Type(x) {
357
+ if (x === null)
358
+ return 1;
359
+ switch (typeof x) {
360
+ case "undefined":
361
+ return 0;
362
+ case "boolean":
363
+ return 2;
364
+ case "string":
365
+ return 3;
366
+ case "symbol":
367
+ return 4;
368
+ case "number":
369
+ return 5;
370
+ case "object":
371
+ return x === null ? 1 : 6;
372
+ default:
373
+ return 6;
374
+ }
375
+ }
376
+ __name(Type, "Type");
377
+ function IsUndefined(x) {
378
+ return x === void 0;
379
+ }
380
+ __name(IsUndefined, "IsUndefined");
381
+ function IsNull(x) {
382
+ return x === null;
383
+ }
384
+ __name(IsNull, "IsNull");
385
+ function IsSymbol(x) {
386
+ return typeof x === "symbol";
387
+ }
388
+ __name(IsSymbol, "IsSymbol");
389
+ function IsObject(x) {
390
+ return typeof x === "object" ? x !== null : typeof x === "function";
391
+ }
392
+ __name(IsObject, "IsObject");
393
+ function ToPrimitive(input, PreferredType) {
394
+ switch (Type(input)) {
395
+ case 0:
396
+ return input;
397
+ case 1:
398
+ return input;
399
+ case 2:
400
+ return input;
401
+ case 3:
402
+ return input;
403
+ case 4:
404
+ return input;
405
+ case 5:
406
+ return input;
407
+ }
408
+ var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
409
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
410
+ if (exoticToPrim !== void 0) {
411
+ var result = exoticToPrim.call(input, hint);
412
+ if (IsObject(result))
413
+ throw new TypeError();
414
+ return result;
415
+ }
416
+ return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
417
+ }
418
+ __name(ToPrimitive, "ToPrimitive");
419
+ function OrdinaryToPrimitive(O, hint) {
420
+ if (hint === "string") {
421
+ var toString_1 = O.toString;
422
+ if (IsCallable(toString_1)) {
423
+ var result = toString_1.call(O);
424
+ if (!IsObject(result))
425
+ return result;
426
+ }
427
+ var valueOf = O.valueOf;
428
+ if (IsCallable(valueOf)) {
429
+ var result = valueOf.call(O);
430
+ if (!IsObject(result))
431
+ return result;
432
+ }
433
+ } else {
434
+ var valueOf = O.valueOf;
435
+ if (IsCallable(valueOf)) {
436
+ var result = valueOf.call(O);
437
+ if (!IsObject(result))
438
+ return result;
439
+ }
440
+ var toString_2 = O.toString;
441
+ if (IsCallable(toString_2)) {
442
+ var result = toString_2.call(O);
443
+ if (!IsObject(result))
444
+ return result;
445
+ }
446
+ }
447
+ throw new TypeError();
448
+ }
449
+ __name(OrdinaryToPrimitive, "OrdinaryToPrimitive");
450
+ function ToBoolean(argument) {
451
+ return !!argument;
452
+ }
453
+ __name(ToBoolean, "ToBoolean");
454
+ function ToString(argument) {
455
+ return "" + argument;
456
+ }
457
+ __name(ToString, "ToString");
458
+ function ToPropertyKey(argument) {
459
+ var key = ToPrimitive(
460
+ argument,
461
+ 3
462
+ /* String */
463
+ );
464
+ if (IsSymbol(key))
465
+ return key;
466
+ return ToString(key);
467
+ }
468
+ __name(ToPropertyKey, "ToPropertyKey");
469
+ function IsArray(argument) {
470
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
471
+ }
472
+ __name(IsArray, "IsArray");
473
+ function IsCallable(argument) {
474
+ return typeof argument === "function";
475
+ }
476
+ __name(IsCallable, "IsCallable");
477
+ function IsConstructor(argument) {
478
+ return typeof argument === "function";
479
+ }
480
+ __name(IsConstructor, "IsConstructor");
481
+ function IsPropertyKey(argument) {
482
+ switch (Type(argument)) {
483
+ case 3:
484
+ return true;
485
+ case 4:
486
+ return true;
487
+ default:
488
+ return false;
489
+ }
490
+ }
491
+ __name(IsPropertyKey, "IsPropertyKey");
492
+ function SameValueZero(x, y) {
493
+ return x === y || x !== x && y !== y;
494
+ }
495
+ __name(SameValueZero, "SameValueZero");
496
+ function GetMethod(V, P) {
497
+ var func = V[P];
498
+ if (func === void 0 || func === null)
499
+ return void 0;
500
+ if (!IsCallable(func))
501
+ throw new TypeError();
502
+ return func;
503
+ }
504
+ __name(GetMethod, "GetMethod");
505
+ function GetIterator(obj) {
506
+ var method = GetMethod(obj, iteratorSymbol);
507
+ if (!IsCallable(method))
508
+ throw new TypeError();
509
+ var iterator = method.call(obj);
510
+ if (!IsObject(iterator))
511
+ throw new TypeError();
512
+ return iterator;
513
+ }
514
+ __name(GetIterator, "GetIterator");
515
+ function IteratorValue(iterResult) {
516
+ return iterResult.value;
517
+ }
518
+ __name(IteratorValue, "IteratorValue");
519
+ function IteratorStep(iterator) {
520
+ var result = iterator.next();
521
+ return result.done ? false : result;
522
+ }
523
+ __name(IteratorStep, "IteratorStep");
524
+ function IteratorClose(iterator) {
525
+ var f = iterator["return"];
526
+ if (f)
527
+ f.call(iterator);
528
+ }
529
+ __name(IteratorClose, "IteratorClose");
530
+ function OrdinaryGetPrototypeOf(O) {
531
+ var proto = Object.getPrototypeOf(O);
532
+ if (typeof O !== "function" || O === functionPrototype)
533
+ return proto;
534
+ if (proto !== functionPrototype)
535
+ return proto;
536
+ var prototype = O.prototype;
537
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
538
+ if (prototypeProto == null || prototypeProto === Object.prototype)
539
+ return proto;
540
+ var constructor = prototypeProto.constructor;
541
+ if (typeof constructor !== "function")
542
+ return proto;
543
+ if (constructor === O)
544
+ return proto;
545
+ return constructor;
546
+ }
547
+ __name(OrdinaryGetPrototypeOf, "OrdinaryGetPrototypeOf");
548
+ function CreateMetadataRegistry() {
549
+ var fallback;
550
+ if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") {
551
+ fallback = CreateFallbackProvider(root.Reflect);
552
+ }
553
+ var first;
554
+ var second;
555
+ var rest;
556
+ var targetProviderMap = new _WeakMap();
557
+ var registry = {
558
+ registerProvider,
559
+ getProvider,
560
+ setProvider
561
+ };
562
+ return registry;
563
+ function registerProvider(provider) {
564
+ if (!Object.isExtensible(registry)) {
565
+ throw new Error("Cannot add provider to a frozen registry.");
566
+ }
567
+ switch (true) {
568
+ case fallback === provider:
569
+ break;
570
+ case IsUndefined(first):
571
+ first = provider;
572
+ break;
573
+ case first === provider:
574
+ break;
575
+ case IsUndefined(second):
576
+ second = provider;
577
+ break;
578
+ case second === provider:
579
+ break;
580
+ default:
581
+ if (rest === void 0)
582
+ rest = new _Set();
583
+ rest.add(provider);
584
+ break;
585
+ }
586
+ }
587
+ __name(registerProvider, "registerProvider");
588
+ function getProviderNoCache(O, P) {
589
+ if (!IsUndefined(first)) {
590
+ if (first.isProviderFor(O, P))
591
+ return first;
592
+ if (!IsUndefined(second)) {
593
+ if (second.isProviderFor(O, P))
594
+ return first;
595
+ if (!IsUndefined(rest)) {
596
+ var iterator = GetIterator(rest);
597
+ while (true) {
598
+ var next = IteratorStep(iterator);
599
+ if (!next) {
600
+ return void 0;
601
+ }
602
+ var provider = IteratorValue(next);
603
+ if (provider.isProviderFor(O, P)) {
604
+ IteratorClose(iterator);
605
+ return provider;
606
+ }
607
+ }
608
+ }
609
+ }
610
+ }
611
+ if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {
612
+ return fallback;
613
+ }
614
+ return void 0;
615
+ }
616
+ __name(getProviderNoCache, "getProviderNoCache");
617
+ function getProvider(O, P) {
618
+ var providerMap = targetProviderMap.get(O);
619
+ var provider;
620
+ if (!IsUndefined(providerMap)) {
621
+ provider = providerMap.get(P);
622
+ }
623
+ if (!IsUndefined(provider)) {
624
+ return provider;
625
+ }
626
+ provider = getProviderNoCache(O, P);
627
+ if (!IsUndefined(provider)) {
628
+ if (IsUndefined(providerMap)) {
629
+ providerMap = new _Map();
630
+ targetProviderMap.set(O, providerMap);
631
+ }
632
+ providerMap.set(P, provider);
633
+ }
634
+ return provider;
635
+ }
636
+ __name(getProvider, "getProvider");
637
+ function hasProvider(provider) {
638
+ if (IsUndefined(provider))
639
+ throw new TypeError();
640
+ return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
641
+ }
642
+ __name(hasProvider, "hasProvider");
643
+ function setProvider(O, P, provider) {
644
+ if (!hasProvider(provider)) {
645
+ throw new Error("Metadata provider not registered.");
646
+ }
647
+ var existingProvider = getProvider(O, P);
648
+ if (existingProvider !== provider) {
649
+ if (!IsUndefined(existingProvider)) {
650
+ return false;
651
+ }
652
+ var providerMap = targetProviderMap.get(O);
653
+ if (IsUndefined(providerMap)) {
654
+ providerMap = new _Map();
655
+ targetProviderMap.set(O, providerMap);
656
+ }
657
+ providerMap.set(P, provider);
658
+ }
659
+ return true;
660
+ }
661
+ __name(setProvider, "setProvider");
662
+ }
663
+ __name(CreateMetadataRegistry, "CreateMetadataRegistry");
664
+ function GetOrCreateMetadataRegistry() {
665
+ var metadataRegistry2;
666
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
667
+ metadataRegistry2 = root.Reflect[registrySymbol];
668
+ }
669
+ if (IsUndefined(metadataRegistry2)) {
670
+ metadataRegistry2 = CreateMetadataRegistry();
671
+ }
672
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
673
+ Object.defineProperty(root.Reflect, registrySymbol, {
674
+ enumerable: false,
675
+ configurable: false,
676
+ writable: false,
677
+ value: metadataRegistry2
678
+ });
679
+ }
680
+ return metadataRegistry2;
681
+ }
682
+ __name(GetOrCreateMetadataRegistry, "GetOrCreateMetadataRegistry");
683
+ function CreateMetadataProvider(registry) {
684
+ var metadata2 = new _WeakMap();
685
+ var provider = {
686
+ isProviderFor: function(O, P) {
687
+ var targetMetadata = metadata2.get(O);
688
+ if (IsUndefined(targetMetadata))
689
+ return false;
690
+ return targetMetadata.has(P);
691
+ },
692
+ OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata2,
693
+ OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata2,
694
+ OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata2,
695
+ OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys2,
696
+ OrdinaryDeleteMetadata
697
+ };
698
+ metadataRegistry.registerProvider(provider);
699
+ return provider;
700
+ function GetOrCreateMetadataMap(O, P, Create) {
701
+ var targetMetadata = metadata2.get(O);
702
+ var createdTargetMetadata = false;
703
+ if (IsUndefined(targetMetadata)) {
704
+ if (!Create)
705
+ return void 0;
706
+ targetMetadata = new _Map();
707
+ metadata2.set(O, targetMetadata);
708
+ createdTargetMetadata = true;
709
+ }
710
+ var metadataMap = targetMetadata.get(P);
711
+ if (IsUndefined(metadataMap)) {
712
+ if (!Create)
713
+ return void 0;
714
+ metadataMap = new _Map();
715
+ targetMetadata.set(P, metadataMap);
716
+ if (!registry.setProvider(O, P, provider)) {
717
+ targetMetadata.delete(P);
718
+ if (createdTargetMetadata) {
719
+ metadata2.delete(O);
720
+ }
721
+ throw new Error("Wrong provider for target.");
722
+ }
723
+ }
724
+ return metadataMap;
725
+ }
726
+ __name(GetOrCreateMetadataMap, "GetOrCreateMetadataMap");
727
+ function OrdinaryHasOwnMetadata2(MetadataKey, O, P) {
728
+ var metadataMap = GetOrCreateMetadataMap(
729
+ O,
730
+ P,
731
+ /*Create*/
732
+ false
733
+ );
734
+ if (IsUndefined(metadataMap))
735
+ return false;
736
+ return ToBoolean(metadataMap.has(MetadataKey));
737
+ }
738
+ __name(OrdinaryHasOwnMetadata2, "OrdinaryHasOwnMetadata");
739
+ function OrdinaryGetOwnMetadata2(MetadataKey, O, P) {
740
+ var metadataMap = GetOrCreateMetadataMap(
741
+ O,
742
+ P,
743
+ /*Create*/
744
+ false
745
+ );
746
+ if (IsUndefined(metadataMap))
747
+ return void 0;
748
+ return metadataMap.get(MetadataKey);
749
+ }
750
+ __name(OrdinaryGetOwnMetadata2, "OrdinaryGetOwnMetadata");
751
+ function OrdinaryDefineOwnMetadata2(MetadataKey, MetadataValue, O, P) {
752
+ var metadataMap = GetOrCreateMetadataMap(
753
+ O,
754
+ P,
755
+ /*Create*/
756
+ true
757
+ );
758
+ metadataMap.set(MetadataKey, MetadataValue);
759
+ }
760
+ __name(OrdinaryDefineOwnMetadata2, "OrdinaryDefineOwnMetadata");
761
+ function OrdinaryOwnMetadataKeys2(O, P) {
762
+ var keys = [];
763
+ var metadataMap = GetOrCreateMetadataMap(
764
+ O,
765
+ P,
766
+ /*Create*/
767
+ false
768
+ );
769
+ if (IsUndefined(metadataMap))
770
+ return keys;
771
+ var keysObj = metadataMap.keys();
772
+ var iterator = GetIterator(keysObj);
773
+ var k = 0;
774
+ while (true) {
775
+ var next = IteratorStep(iterator);
776
+ if (!next) {
777
+ keys.length = k;
778
+ return keys;
779
+ }
780
+ var nextValue = IteratorValue(next);
781
+ try {
782
+ keys[k] = nextValue;
783
+ } catch (e) {
784
+ try {
785
+ IteratorClose(iterator);
786
+ } finally {
787
+ throw e;
788
+ }
789
+ }
790
+ k++;
791
+ }
792
+ }
793
+ __name(OrdinaryOwnMetadataKeys2, "OrdinaryOwnMetadataKeys");
794
+ function OrdinaryDeleteMetadata(MetadataKey, O, P) {
795
+ var metadataMap = GetOrCreateMetadataMap(
796
+ O,
797
+ P,
798
+ /*Create*/
799
+ false
800
+ );
801
+ if (IsUndefined(metadataMap))
802
+ return false;
803
+ if (!metadataMap.delete(MetadataKey))
804
+ return false;
805
+ if (metadataMap.size === 0) {
806
+ var targetMetadata = metadata2.get(O);
807
+ if (!IsUndefined(targetMetadata)) {
808
+ targetMetadata.delete(P);
809
+ if (targetMetadata.size === 0) {
810
+ metadata2.delete(targetMetadata);
811
+ }
812
+ }
813
+ }
814
+ return true;
815
+ }
816
+ __name(OrdinaryDeleteMetadata, "OrdinaryDeleteMetadata");
817
+ }
818
+ __name(CreateMetadataProvider, "CreateMetadataProvider");
819
+ function CreateFallbackProvider(reflect) {
820
+ var defineMetadata2 = reflect.defineMetadata, hasOwnMetadata2 = reflect.hasOwnMetadata, getOwnMetadata2 = reflect.getOwnMetadata, getOwnMetadataKeys2 = reflect.getOwnMetadataKeys, deleteMetadata2 = reflect.deleteMetadata;
821
+ var metadataOwner = new _WeakMap();
822
+ var provider = {
823
+ isProviderFor: function(O, P) {
824
+ var metadataPropertySet = metadataOwner.get(O);
825
+ if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {
826
+ return true;
827
+ }
828
+ if (getOwnMetadataKeys2(O, P).length) {
829
+ if (IsUndefined(metadataPropertySet)) {
830
+ metadataPropertySet = new _Set();
831
+ metadataOwner.set(O, metadataPropertySet);
832
+ }
833
+ metadataPropertySet.add(P);
834
+ return true;
835
+ }
836
+ return false;
837
+ },
838
+ OrdinaryDefineOwnMetadata: defineMetadata2,
839
+ OrdinaryHasOwnMetadata: hasOwnMetadata2,
840
+ OrdinaryGetOwnMetadata: getOwnMetadata2,
841
+ OrdinaryOwnMetadataKeys: getOwnMetadataKeys2,
842
+ OrdinaryDeleteMetadata: deleteMetadata2
843
+ };
844
+ return provider;
845
+ }
846
+ __name(CreateFallbackProvider, "CreateFallbackProvider");
847
+ function GetMetadataProvider(O, P, Create) {
848
+ var registeredProvider = metadataRegistry.getProvider(O, P);
849
+ if (!IsUndefined(registeredProvider)) {
850
+ return registeredProvider;
851
+ }
852
+ if (Create) {
853
+ if (metadataRegistry.setProvider(O, P, metadataProvider)) {
854
+ return metadataProvider;
855
+ }
856
+ throw new Error("Illegal state.");
857
+ }
858
+ return void 0;
859
+ }
860
+ __name(GetMetadataProvider, "GetMetadataProvider");
861
+ function CreateMapPolyfill() {
862
+ var cacheSentinel = {};
863
+ var arraySentinel = [];
864
+ var MapIterator = (
865
+ /** @class */
866
+ function() {
867
+ function MapIterator2(keys, values, selector) {
868
+ this._index = 0;
869
+ this._keys = keys;
870
+ this._values = values;
871
+ this._selector = selector;
872
+ }
873
+ __name(MapIterator2, "MapIterator");
874
+ MapIterator2.prototype["@@iterator"] = function() {
875
+ return this;
876
+ };
877
+ MapIterator2.prototype[iteratorSymbol] = function() {
878
+ return this;
879
+ };
880
+ MapIterator2.prototype.next = function() {
881
+ var index = this._index;
882
+ if (index >= 0 && index < this._keys.length) {
883
+ var result = this._selector(this._keys[index], this._values[index]);
884
+ if (index + 1 >= this._keys.length) {
885
+ this._index = -1;
886
+ this._keys = arraySentinel;
887
+ this._values = arraySentinel;
888
+ } else {
889
+ this._index++;
890
+ }
891
+ return {
892
+ value: result,
893
+ done: false
894
+ };
895
+ }
896
+ return {
897
+ value: void 0,
898
+ done: true
899
+ };
900
+ };
901
+ MapIterator2.prototype.throw = function(error) {
902
+ if (this._index >= 0) {
903
+ this._index = -1;
904
+ this._keys = arraySentinel;
905
+ this._values = arraySentinel;
906
+ }
907
+ throw error;
908
+ };
909
+ MapIterator2.prototype.return = function(value) {
910
+ if (this._index >= 0) {
911
+ this._index = -1;
912
+ this._keys = arraySentinel;
913
+ this._values = arraySentinel;
914
+ }
915
+ return {
916
+ value,
917
+ done: true
918
+ };
919
+ };
920
+ return MapIterator2;
921
+ }()
922
+ );
923
+ var Map1 = (
924
+ /** @class */
925
+ function() {
926
+ function Map12() {
927
+ this._keys = [];
928
+ this._values = [];
929
+ this._cacheKey = cacheSentinel;
930
+ this._cacheIndex = -2;
931
+ }
932
+ __name(Map12, "Map1");
933
+ Object.defineProperty(Map12.prototype, "size", {
934
+ get: function() {
935
+ return this._keys.length;
936
+ },
937
+ enumerable: true,
938
+ configurable: true
939
+ });
940
+ Map12.prototype.has = function(key) {
941
+ return this._find(
942
+ key,
943
+ /*insert*/
944
+ false
945
+ ) >= 0;
946
+ };
947
+ Map12.prototype.get = function(key) {
948
+ var index = this._find(
949
+ key,
950
+ /*insert*/
951
+ false
952
+ );
953
+ return index >= 0 ? this._values[index] : void 0;
954
+ };
955
+ Map12.prototype.set = function(key, value) {
956
+ var index = this._find(
957
+ key,
958
+ /*insert*/
959
+ true
960
+ );
961
+ this._values[index] = value;
962
+ return this;
963
+ };
964
+ Map12.prototype.delete = function(key) {
965
+ var index = this._find(
966
+ key,
967
+ /*insert*/
968
+ false
969
+ );
970
+ if (index >= 0) {
971
+ var size = this._keys.length;
972
+ for (var i = index + 1; i < size; i++) {
973
+ this._keys[i - 1] = this._keys[i];
974
+ this._values[i - 1] = this._values[i];
975
+ }
976
+ this._keys.length--;
977
+ this._values.length--;
978
+ if (SameValueZero(key, this._cacheKey)) {
979
+ this._cacheKey = cacheSentinel;
980
+ this._cacheIndex = -2;
981
+ }
982
+ return true;
983
+ }
984
+ return false;
985
+ };
986
+ Map12.prototype.clear = function() {
987
+ this._keys.length = 0;
988
+ this._values.length = 0;
989
+ this._cacheKey = cacheSentinel;
990
+ this._cacheIndex = -2;
991
+ };
992
+ Map12.prototype.keys = function() {
993
+ return new MapIterator(this._keys, this._values, getKey);
994
+ };
995
+ Map12.prototype.values = function() {
996
+ return new MapIterator(this._keys, this._values, getValue);
997
+ };
998
+ Map12.prototype.entries = function() {
999
+ return new MapIterator(this._keys, this._values, getEntry);
1000
+ };
1001
+ Map12.prototype["@@iterator"] = function() {
1002
+ return this.entries();
1003
+ };
1004
+ Map12.prototype[iteratorSymbol] = function() {
1005
+ return this.entries();
1006
+ };
1007
+ Map12.prototype._find = function(key, insert) {
1008
+ if (!SameValueZero(this._cacheKey, key)) {
1009
+ this._cacheIndex = -1;
1010
+ for (var i = 0; i < this._keys.length; i++) {
1011
+ if (SameValueZero(this._keys[i], key)) {
1012
+ this._cacheIndex = i;
1013
+ break;
1014
+ }
1015
+ }
1016
+ }
1017
+ if (this._cacheIndex < 0 && insert) {
1018
+ this._cacheIndex = this._keys.length;
1019
+ this._keys.push(key);
1020
+ this._values.push(void 0);
1021
+ }
1022
+ return this._cacheIndex;
1023
+ };
1024
+ return Map12;
1025
+ }()
1026
+ );
1027
+ return Map1;
1028
+ function getKey(key, _) {
1029
+ return key;
1030
+ }
1031
+ __name(getKey, "getKey");
1032
+ function getValue(_, value) {
1033
+ return value;
1034
+ }
1035
+ __name(getValue, "getValue");
1036
+ function getEntry(key, value) {
1037
+ return [
1038
+ key,
1039
+ value
1040
+ ];
1041
+ }
1042
+ __name(getEntry, "getEntry");
1043
+ }
1044
+ __name(CreateMapPolyfill, "CreateMapPolyfill");
1045
+ function CreateSetPolyfill() {
1046
+ var Set1 = (
1047
+ /** @class */
1048
+ function() {
1049
+ function Set12() {
1050
+ this._map = new _Map();
1051
+ }
1052
+ __name(Set12, "Set1");
1053
+ Object.defineProperty(Set12.prototype, "size", {
1054
+ get: function() {
1055
+ return this._map.size;
1056
+ },
1057
+ enumerable: true,
1058
+ configurable: true
1059
+ });
1060
+ Set12.prototype.has = function(value) {
1061
+ return this._map.has(value);
1062
+ };
1063
+ Set12.prototype.add = function(value) {
1064
+ return this._map.set(value, value), this;
1065
+ };
1066
+ Set12.prototype.delete = function(value) {
1067
+ return this._map.delete(value);
1068
+ };
1069
+ Set12.prototype.clear = function() {
1070
+ this._map.clear();
1071
+ };
1072
+ Set12.prototype.keys = function() {
1073
+ return this._map.keys();
1074
+ };
1075
+ Set12.prototype.values = function() {
1076
+ return this._map.keys();
1077
+ };
1078
+ Set12.prototype.entries = function() {
1079
+ return this._map.entries();
1080
+ };
1081
+ Set12.prototype["@@iterator"] = function() {
1082
+ return this.keys();
1083
+ };
1084
+ Set12.prototype[iteratorSymbol] = function() {
1085
+ return this.keys();
1086
+ };
1087
+ return Set12;
1088
+ }()
1089
+ );
1090
+ return Set1;
1091
+ }
1092
+ __name(CreateSetPolyfill, "CreateSetPolyfill");
1093
+ function CreateWeakMapPolyfill() {
1094
+ var UUID_SIZE = 16;
1095
+ var keys = HashMap.create();
1096
+ var rootKey = CreateUniqueKey();
1097
+ return (
1098
+ /** @class */
1099
+ function() {
1100
+ function WeakMap1() {
1101
+ this._key = CreateUniqueKey();
1102
+ }
1103
+ __name(WeakMap1, "WeakMap1");
1104
+ WeakMap1.prototype.has = function(target) {
1105
+ var table = GetOrCreateWeakMapTable(
1106
+ target,
1107
+ /*create*/
1108
+ false
1109
+ );
1110
+ return table !== void 0 ? HashMap.has(table, this._key) : false;
1111
+ };
1112
+ WeakMap1.prototype.get = function(target) {
1113
+ var table = GetOrCreateWeakMapTable(
1114
+ target,
1115
+ /*create*/
1116
+ false
1117
+ );
1118
+ return table !== void 0 ? HashMap.get(table, this._key) : void 0;
1119
+ };
1120
+ WeakMap1.prototype.set = function(target, value) {
1121
+ var table = GetOrCreateWeakMapTable(
1122
+ target,
1123
+ /*create*/
1124
+ true
1125
+ );
1126
+ table[this._key] = value;
1127
+ return this;
1128
+ };
1129
+ WeakMap1.prototype.delete = function(target) {
1130
+ var table = GetOrCreateWeakMapTable(
1131
+ target,
1132
+ /*create*/
1133
+ false
1134
+ );
1135
+ return table !== void 0 ? delete table[this._key] : false;
1136
+ };
1137
+ WeakMap1.prototype.clear = function() {
1138
+ this._key = CreateUniqueKey();
1139
+ };
1140
+ return WeakMap1;
1141
+ }()
1142
+ );
1143
+ function CreateUniqueKey() {
1144
+ var key;
1145
+ do
1146
+ key = "@@WeakMap@@" + CreateUUID();
1147
+ while (HashMap.has(keys, key));
1148
+ keys[key] = true;
1149
+ return key;
1150
+ }
1151
+ __name(CreateUniqueKey, "CreateUniqueKey");
1152
+ function GetOrCreateWeakMapTable(target, create) {
1153
+ if (!hasOwn.call(target, rootKey)) {
1154
+ if (!create)
1155
+ return void 0;
1156
+ Object.defineProperty(target, rootKey, {
1157
+ value: HashMap.create()
1158
+ });
1159
+ }
1160
+ return target[rootKey];
1161
+ }
1162
+ __name(GetOrCreateWeakMapTable, "GetOrCreateWeakMapTable");
1163
+ function FillRandomBytes(buffer, size) {
1164
+ for (var i = 0; i < size; ++i)
1165
+ buffer[i] = Math.random() * 255 | 0;
1166
+ return buffer;
1167
+ }
1168
+ __name(FillRandomBytes, "FillRandomBytes");
1169
+ function GenRandomBytes(size) {
1170
+ if (typeof Uint8Array === "function") {
1171
+ var array = new Uint8Array(size);
1172
+ if (typeof crypto !== "undefined") {
1173
+ crypto.getRandomValues(array);
1174
+ } else if (typeof msCrypto !== "undefined") {
1175
+ msCrypto.getRandomValues(array);
1176
+ } else {
1177
+ FillRandomBytes(array, size);
1178
+ }
1179
+ return array;
1180
+ }
1181
+ return FillRandomBytes(new Array(size), size);
1182
+ }
1183
+ __name(GenRandomBytes, "GenRandomBytes");
1184
+ function CreateUUID() {
1185
+ var data = GenRandomBytes(UUID_SIZE);
1186
+ data[6] = data[6] & 79 | 64;
1187
+ data[8] = data[8] & 191 | 128;
1188
+ var result = "";
1189
+ for (var offset = 0; offset < UUID_SIZE; ++offset) {
1190
+ var byte = data[offset];
1191
+ if (offset === 4 || offset === 6 || offset === 8)
1192
+ result += "-";
1193
+ if (byte < 16)
1194
+ result += "0";
1195
+ result += byte.toString(16).toLowerCase();
1196
+ }
1197
+ return result;
1198
+ }
1199
+ __name(CreateUUID, "CreateUUID");
1200
+ }
1201
+ __name(CreateWeakMapPolyfill, "CreateWeakMapPolyfill");
1202
+ function MakeDictionary(obj) {
1203
+ obj.__ = void 0;
1204
+ delete obj.__;
1205
+ return obj;
1206
+ }
1207
+ __name(MakeDictionary, "MakeDictionary");
1208
+ });
1209
+ })(Reflect2 || (Reflect2 = {}));
1210
+ }
1211
+ });
3
1212
 
4
1213
  // src/Route.ts
1214
+ var import_reflect_metadata = __toESM(require_Reflect(), 1);
1215
+ import { Container, Kernel } from "@h3ravel/core";
5
1216
  import { Request, Response } from "@h3ravel/http";
6
- import { Container, Controller, Kernel } from "@h3ravel/core";
7
- import { afterLast } from "@h3ravel/support";
1217
+ import { singularize } from "@h3ravel/support";
1218
+ import { HttpContext } from "@h3ravel/shared";
8
1219
  var Router = class {
9
1220
  static {
10
1221
  __name(this, "Router");
@@ -29,7 +1240,7 @@ var Router = class {
29
1240
  */
30
1241
  resolveHandler(handler, middleware = []) {
31
1242
  return async (event) => {
32
- const kernel = new Kernel(() => ({
1243
+ const kernel = new Kernel(() => HttpContext.init({
33
1244
  app: this.app,
34
1245
  request: new Request(event, this.app),
35
1246
  response: new Response(event, this.app)
@@ -62,9 +1273,23 @@ var Router = class {
62
1273
  });
63
1274
  this.h3App[method](fullPath, this.resolveHandler(handler, middleware));
64
1275
  }
1276
+ /**
1277
+ * Resolves a route handler definition into an executable EventHandler.
1278
+ *
1279
+ * A handler can be:
1280
+ * - A function matching the EventHandler signature
1281
+ * - A controller class (optionally decorated for IoC resolution)
1282
+ *
1283
+ * If it’s a controller class, this method will:
1284
+ * - Instantiate it (via IoC or manually)
1285
+ * - Call the specified method (defaults to `index`)
1286
+ *
1287
+ * @param handler Event handler function OR controller class
1288
+ * @param methodName Method to invoke on the controller (defaults to 'index')
1289
+ */
65
1290
  resolveControllerOrHandler(handler, methodName) {
66
- if (typeof handler === "function" && handler.prototype instanceof Controller) {
67
- return (ctx) => {
1291
+ if (typeof handler === "function") {
1292
+ return (_ctx) => {
68
1293
  let controller;
69
1294
  if (Container.hasAnyDecorator(handler)) {
70
1295
  controller = this.app.make(handler);
@@ -75,29 +1300,100 @@ var Router = class {
75
1300
  if (typeof controller[action] !== "function") {
76
1301
  throw new Error(`Method "${String(action)}" not found on controller ${handler.name}`);
77
1302
  }
78
- return controller[action](ctx);
1303
+ const paramTypes = Reflect.getMetadata("design:paramtypes", controller, action) || [];
1304
+ const args = paramTypes.map((paramType) => {
1305
+ switch (paramType?.name) {
1306
+ case "Application":
1307
+ return this.app;
1308
+ case "Request":
1309
+ return _ctx.request;
1310
+ case "Response":
1311
+ return _ctx.response;
1312
+ case "HttpContext":
1313
+ return _ctx;
1314
+ default:
1315
+ return this.app.make(paramType);
1316
+ }
1317
+ });
1318
+ return controller[action](...args);
79
1319
  };
80
1320
  }
81
1321
  return handler;
82
1322
  }
1323
+ /**
1324
+ * Registers a route that responds to HTTP GET requests.
1325
+ *
1326
+ * @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
1327
+ * @param definition Either:
1328
+ * - An EventHandler function
1329
+ * - A tuple: [ControllerClass, methodName]
1330
+ * @param name Optional route name (for URL generation or referencing).
1331
+ * @param middleware Optional array of middleware functions to execute before the handler.
1332
+ */
83
1333
  get(path2, definition, name, middleware = []) {
84
1334
  const handler = Array.isArray(definition) ? definition[0] : definition;
85
1335
  const methodName = Array.isArray(definition) ? definition[1] : void 0;
86
1336
  this.addRoute("get", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
87
1337
  return this;
88
1338
  }
1339
+ /**
1340
+ * Registers a route that responds to HTTP POST requests.
1341
+ *
1342
+ * @param path The URL pattern to match (can include parameters, e.g., '/users').
1343
+ * @param definition Either:
1344
+ * - An EventHandler function
1345
+ * - A tuple: [ControllerClass, methodName]
1346
+ * @param name Optional route name (for URL generation or referencing).
1347
+ * @param middleware Optional array of middleware functions to execute before the handler.
1348
+ */
89
1349
  post(path2, definition, name, middleware = []) {
90
1350
  const handler = Array.isArray(definition) ? definition[0] : definition;
91
1351
  const methodName = Array.isArray(definition) ? definition[1] : void 0;
92
1352
  this.addRoute("post", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
93
1353
  return this;
94
1354
  }
1355
+ /**
1356
+ * Registers a route that responds to HTTP PUT requests.
1357
+ *
1358
+ * @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
1359
+ * @param definition Either:
1360
+ * - An EventHandler function
1361
+ * - A tuple: [ControllerClass, methodName]
1362
+ * @param name Optional route name (for URL generation or referencing).
1363
+ * @param middleware Optional array of middleware functions to execute before the handler.
1364
+ */
95
1365
  put(path2, definition, name, middleware = []) {
96
1366
  const handler = Array.isArray(definition) ? definition[0] : definition;
97
1367
  const methodName = Array.isArray(definition) ? definition[1] : void 0;
98
1368
  this.addRoute("put", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
99
1369
  return this;
100
1370
  }
1371
+ /**
1372
+ * Registers a route that responds to HTTP PATCH requests.
1373
+ *
1374
+ * @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
1375
+ * @param definition Either:
1376
+ * - An EventHandler function
1377
+ * - A tuple: [ControllerClass, methodName]
1378
+ * @param name Optional route name (for URL generation or referencing).
1379
+ * @param middleware Optional array of middleware functions to execute before the handler.
1380
+ */
1381
+ patch(path2, definition, name, middleware = []) {
1382
+ const handler = Array.isArray(definition) ? definition[0] : definition;
1383
+ const methodName = Array.isArray(definition) ? definition[1] : void 0;
1384
+ this.addRoute("patch", path2, this.resolveControllerOrHandler(handler, methodName), name, middleware);
1385
+ return this;
1386
+ }
1387
+ /**
1388
+ * Registers a route that responds to HTTP DELETE requests.
1389
+ *
1390
+ * @param path The URL pattern to match (can include parameters, e.g., '/users/:id').
1391
+ * @param definition Either:
1392
+ * - An EventHandler function
1393
+ * - A tuple: [ControllerClass, methodName]
1394
+ * @param name Optional route name (for URL generation or referencing).
1395
+ * @param middleware Optional array of middleware functions to execute before the handler.
1396
+ */
101
1397
  delete(path2, definition, name, middleware = []) {
102
1398
  const handler = Array.isArray(definition) ? definition[0] : definition;
103
1399
  const methodName = Array.isArray(definition) ? definition[1] : void 0;
@@ -110,17 +1406,18 @@ var Router = class {
110
1406
  * @param path
111
1407
  * @param controller
112
1408
  */
113
- apiResource(path2, Controller2, middleware = []) {
1409
+ apiResource(path2, Controller, middleware = []) {
114
1410
  path2 = path2.replace(/\//g, "/");
115
- const name = afterLast(path2, "/");
116
- const basePath = `/${path2}`.replace(/\/+/g, "/");
117
- const controller = new Controller2(this.app);
1411
+ const basePath = `/${path2}`.replace(/\/+$/, "").replace(/(\/)+/g, "$1");
1412
+ const name = basePath.substring(basePath.lastIndexOf("/") + 1).replaceAll(/\/|:/g, "") || "";
1413
+ const param = singularize(name);
1414
+ const controller = new Controller(this.app);
118
1415
  this.addRoute("get", basePath, controller.index.bind(controller), `${name}.index`, middleware);
119
1416
  this.addRoute("post", basePath, controller.store.bind(controller), `${name}.store`, middleware);
120
- this.addRoute("get", `${basePath}/:id`, controller.show.bind(controller), `${name}.show`, middleware);
121
- this.addRoute("put", `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware);
122
- this.addRoute("patch", `${basePath}/:id`, controller.update.bind(controller), `${name}.update`, middleware);
123
- this.addRoute("delete", `${basePath}/:id`, controller.destroy.bind(controller), `${name}.destroy`, middleware);
1417
+ this.addRoute("get", `${basePath}/:${param}`, controller.show.bind(controller), `${name}.show`, middleware);
1418
+ this.addRoute("put", `${basePath}/:${param}`, controller.update.bind(controller), `${name}.update`, middleware);
1419
+ this.addRoute("patch", `${basePath}/:${param}`, controller.update.bind(controller), `${name}.update`, middleware);
1420
+ this.addRoute("delete", `${basePath}/:${param}`, controller.destroy.bind(controller), `${name}.destroy`, middleware);
124
1421
  return this;
125
1422
  }
126
1423
  /**
@@ -237,7 +1534,7 @@ var AssetsServiceProvider = class extends ServiceProvider {
237
1534
 
238
1535
  // src/Providers/RouteServiceProvider.ts
239
1536
  import { ServiceProvider as ServiceProvider2 } from "@h3ravel/core";
240
- import path from "path";
1537
+ import path from "node:path";
241
1538
  import { readdir } from "node:fs/promises";
242
1539
  var RouteServiceProvider = class extends ServiceProvider2 {
243
1540
  static {
@@ -276,4 +1573,22 @@ export {
276
1573
  RouteServiceProvider,
277
1574
  Router
278
1575
  };
1576
+ /*! Bundled license information:
1577
+
1578
+ reflect-metadata/Reflect.js:
1579
+ (*! *****************************************************************************
1580
+ Copyright (C) Microsoft. All rights reserved.
1581
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
1582
+ this file except in compliance with the License. You may obtain a copy of the
1583
+ License at http://www.apache.org/licenses/LICENSE-2.0
1584
+
1585
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1586
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
1587
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
1588
+ MERCHANTABLITY OR NON-INFRINGEMENT.
1589
+
1590
+ See the Apache Version 2.0 License for specific language governing permissions
1591
+ and limitations under the License.
1592
+ ***************************************************************************** *)
1593
+ */
279
1594
  //# sourceMappingURL=index.js.map