@bepalo/spine 3.12.27 → 3.15.30
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/README.md +793 -1048
- package/dist/auth-middlewares.d.ts +7 -7
- package/dist/auth-middlewares.d.ts.map +1 -1
- package/dist/auth-middlewares.js.map +1 -1
- package/dist/cjs/auth-middlewares.d.ts +7 -7
- package/dist/cjs/auth-middlewares.d.ts.map +1 -1
- package/dist/cjs/auth-middlewares.js.map +1 -1
- package/dist/cjs/helpers.d.ts +17 -13
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +51 -46
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/middlewares.d.ts +71 -5
- package/dist/cjs/middlewares.d.ts.map +1 -1
- package/dist/cjs/middlewares.js +100 -26
- package/dist/cjs/middlewares.js.map +1 -1
- package/dist/cjs/parsers.d.ts +4 -1
- package/dist/cjs/parsers.d.ts.map +1 -1
- package/dist/cjs/parsers.js +50 -18
- package/dist/cjs/parsers.js.map +1 -1
- package/dist/cjs/router.d.ts +47 -0
- package/dist/cjs/router.d.ts.map +1 -1
- package/dist/cjs/router.js +433 -3
- package/dist/cjs/router.js.map +1 -1
- package/dist/cjs/types.d.ts +8 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/helpers.d.ts +17 -13
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +51 -46
- package/dist/helpers.js.map +1 -1
- package/dist/middlewares.d.ts +71 -5
- package/dist/middlewares.d.ts.map +1 -1
- package/dist/middlewares.js +100 -26
- package/dist/middlewares.js.map +1 -1
- package/dist/parsers.d.ts +4 -1
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +50 -18
- package/dist/parsers.js.map +1 -1
- package/dist/router.d.ts +47 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +433 -3
- package/dist/router.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/router.js
CHANGED
|
@@ -431,6 +431,20 @@ class Router {
|
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
434
|
+
* Register routes defined in the other router to this router.
|
|
435
|
+
*
|
|
436
|
+
* @param {Router<_ExtendContext,ExtendContext>} router The router to append routes definitions from.
|
|
437
|
+
* @param {{overwrite:boolean}} options Options to apply to each route definition.
|
|
438
|
+
* @param {boolean} [options.overwrite] Overwrite each route definition. This overrides the route specific options.
|
|
439
|
+
*/
|
|
440
|
+
append(router, options) {
|
|
441
|
+
const overwrite = options === null || options === void 0 ? void 0 : options.overwrite;
|
|
442
|
+
for (const { handlerType, methodPaths, pipe, options: setterOptions, } of __classPrivateFieldGet(router, _Router_setters, "f")) {
|
|
443
|
+
this.register(handlerType, methodPaths, pipe, Object.assign(Object.assign({}, setterOptions), { overwrite: (setterOptions === null || setterOptions === void 0 ? void 0 : setterOptions.overwrite) || overwrite }));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Register routes defined in the other router to this router under the prefix path.
|
|
434
448
|
*
|
|
435
449
|
* @param {string} prefix Path prefix to prepend to paths.
|
|
436
450
|
* @param {Router<_ExtendContext,ExtendContext>} router The router to append routes definitions from.
|
|
@@ -2463,6 +2477,9 @@ class Router {
|
|
|
2463
2477
|
if (superGlobEntries == null) {
|
|
2464
2478
|
superGlobEntries = new Map();
|
|
2465
2479
|
routes.superGlobs[parts_len_1] = superGlobEntries;
|
|
2480
|
+
if (routes.superGlobsIndices.indexOf(parts_len_1) === -1) {
|
|
2481
|
+
routes.superGlobsIndices.push(parts_len_1);
|
|
2482
|
+
}
|
|
2466
2483
|
}
|
|
2467
2484
|
superGlobEntries.set(basePath, entry);
|
|
2468
2485
|
}
|
|
@@ -2494,6 +2511,9 @@ class Router {
|
|
|
2494
2511
|
if (globEntries == null) {
|
|
2495
2512
|
globEntries = new Map();
|
|
2496
2513
|
routes.globs[parts.length] = globEntries;
|
|
2514
|
+
if (routes.globsIndices.indexOf(parts.length) === -1) {
|
|
2515
|
+
routes.globsIndices.push(parts.length);
|
|
2516
|
+
}
|
|
2497
2517
|
}
|
|
2498
2518
|
globEntries.set(path, entry);
|
|
2499
2519
|
}
|
|
@@ -2505,6 +2525,9 @@ class Router {
|
|
|
2505
2525
|
if (entries == null) {
|
|
2506
2526
|
entries = new Map();
|
|
2507
2527
|
routes.entries[parts.length] = entries;
|
|
2528
|
+
if (routes.entriesIndices.indexOf(parts.length) === -1) {
|
|
2529
|
+
routes.entriesIndices.push(parts.length);
|
|
2530
|
+
}
|
|
2508
2531
|
}
|
|
2509
2532
|
entries.set(path, entry);
|
|
2510
2533
|
}
|
|
@@ -2514,9 +2537,11 @@ class Router {
|
|
|
2514
2537
|
if (!__classPrivateFieldGet(this, _Router_config, "f").doNotStoreSetters) {
|
|
2515
2538
|
__classPrivateFieldGet(this, _Router_setters, "f").push(Object.freeze({
|
|
2516
2539
|
handlerType,
|
|
2517
|
-
methodPaths
|
|
2518
|
-
|
|
2519
|
-
|
|
2540
|
+
methodPaths: Array.isArray(methodPaths)
|
|
2541
|
+
? Object.freeze(methodPaths)
|
|
2542
|
+
: methodPaths,
|
|
2543
|
+
pipe: Array.isArray(pipe) ? Object.freeze(pipe) : pipe,
|
|
2544
|
+
options: typeof options === "object" ? Object.freeze(options) : options,
|
|
2520
2545
|
}));
|
|
2521
2546
|
}
|
|
2522
2547
|
return this;
|
|
@@ -2557,6 +2582,408 @@ class Router {
|
|
|
2557
2582
|
}
|
|
2558
2583
|
return count;
|
|
2559
2584
|
}
|
|
2585
|
+
/**
|
|
2586
|
+
* Generates a routes object keyed by pathname then by method then by handler-type.
|
|
2587
|
+
*
|
|
2588
|
+
* @returns Routes object
|
|
2589
|
+
*/
|
|
2590
|
+
getRoutesByPathnameThenMethod() {
|
|
2591
|
+
const routes = {};
|
|
2592
|
+
for (const handlerType of Object.keys(__classPrivateFieldGet(this, _Router_routes, "f"))) {
|
|
2593
|
+
const entry0 = __classPrivateFieldGet(this, _Router_routes, "f")[handlerType];
|
|
2594
|
+
for (const methodUpper of Object.keys(entry0)) {
|
|
2595
|
+
const entry1 = entry0[methodUpper];
|
|
2596
|
+
// super-globs
|
|
2597
|
+
for (const superGlobEntryIdx of entry1.superGlobsIndices) {
|
|
2598
|
+
const superGlobEntries = entry1.superGlobs[superGlobEntryIdx];
|
|
2599
|
+
for (const [, entry] of superGlobEntries) {
|
|
2600
|
+
if (!entry.pipe) {
|
|
2601
|
+
continue;
|
|
2602
|
+
}
|
|
2603
|
+
if (!routes[entry.standardPath]) {
|
|
2604
|
+
routes[entry.standardPath] = {};
|
|
2605
|
+
}
|
|
2606
|
+
if (!routes[entry.standardPath][methodUpper]) {
|
|
2607
|
+
routes[entry.standardPath][methodUpper] = {};
|
|
2608
|
+
}
|
|
2609
|
+
routes[entry.standardPath][methodUpper][handlerType] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
// globs
|
|
2613
|
+
for (const globEntryIdx of entry1.globsIndices) {
|
|
2614
|
+
const globEntries = entry1.globs[globEntryIdx];
|
|
2615
|
+
for (const [, entry] of globEntries) {
|
|
2616
|
+
if (!entry.pipe) {
|
|
2617
|
+
continue;
|
|
2618
|
+
}
|
|
2619
|
+
if (!routes[entry.standardPath]) {
|
|
2620
|
+
routes[entry.standardPath] = {};
|
|
2621
|
+
}
|
|
2622
|
+
if (!routes[entry.standardPath][methodUpper]) {
|
|
2623
|
+
routes[entry.standardPath][methodUpper] = {};
|
|
2624
|
+
}
|
|
2625
|
+
routes[entry.standardPath][methodUpper][handlerType] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
// normal paths
|
|
2629
|
+
for (const entryIdx of entry1.entriesIndices) {
|
|
2630
|
+
const entries = entry1.entries[entryIdx];
|
|
2631
|
+
for (const [, entry] of entries) {
|
|
2632
|
+
if (!entry.pipe) {
|
|
2633
|
+
continue;
|
|
2634
|
+
}
|
|
2635
|
+
if (!routes[entry.standardPath]) {
|
|
2636
|
+
routes[entry.standardPath] = {};
|
|
2637
|
+
}
|
|
2638
|
+
if (!routes[entry.standardPath][methodUpper]) {
|
|
2639
|
+
routes[entry.standardPath][methodUpper] = {};
|
|
2640
|
+
}
|
|
2641
|
+
routes[entry.standardPath][methodUpper][handlerType] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
return routes;
|
|
2647
|
+
}
|
|
2648
|
+
/**
|
|
2649
|
+
* Generates a routes object keyed by pathname then by handler-type then by method.
|
|
2650
|
+
*
|
|
2651
|
+
* @returns Routes object
|
|
2652
|
+
*/
|
|
2653
|
+
getRoutesByPathnameThenHandlerType() {
|
|
2654
|
+
const routes = {};
|
|
2655
|
+
for (const handlerType of Object.keys(__classPrivateFieldGet(this, _Router_routes, "f"))) {
|
|
2656
|
+
const entry0 = __classPrivateFieldGet(this, _Router_routes, "f")[handlerType];
|
|
2657
|
+
for (const methodUpper of Object.keys(entry0)) {
|
|
2658
|
+
const entry1 = entry0[methodUpper];
|
|
2659
|
+
// super-globs
|
|
2660
|
+
for (const superGlobEntryIdx of entry1.superGlobsIndices) {
|
|
2661
|
+
const superGlobEntries = entry1.superGlobs[superGlobEntryIdx];
|
|
2662
|
+
for (const [, entry] of superGlobEntries) {
|
|
2663
|
+
if (!entry.pipe) {
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
if (!routes[entry.standardPath]) {
|
|
2667
|
+
routes[entry.standardPath] = {};
|
|
2668
|
+
}
|
|
2669
|
+
if (!routes[entry.standardPath][handlerType]) {
|
|
2670
|
+
routes[entry.standardPath][handlerType] =
|
|
2671
|
+
{};
|
|
2672
|
+
}
|
|
2673
|
+
routes[entry.standardPath][handlerType][methodUpper] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
// globs
|
|
2677
|
+
for (const globEntryIdx of entry1.globsIndices) {
|
|
2678
|
+
const globEntries = entry1.globs[globEntryIdx];
|
|
2679
|
+
for (const [, entry] of globEntries) {
|
|
2680
|
+
if (!entry.pipe) {
|
|
2681
|
+
continue;
|
|
2682
|
+
}
|
|
2683
|
+
if (!routes[entry.standardPath]) {
|
|
2684
|
+
routes[entry.standardPath] = {};
|
|
2685
|
+
}
|
|
2686
|
+
if (!routes[entry.standardPath][handlerType]) {
|
|
2687
|
+
routes[entry.standardPath][handlerType] =
|
|
2688
|
+
{};
|
|
2689
|
+
}
|
|
2690
|
+
routes[entry.standardPath][handlerType][methodUpper] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
// normal paths
|
|
2694
|
+
for (const entryIdx of entry1.entriesIndices) {
|
|
2695
|
+
const entries = entry1.entries[entryIdx];
|
|
2696
|
+
for (const [, entry] of entries) {
|
|
2697
|
+
if (!entry.pipe) {
|
|
2698
|
+
continue;
|
|
2699
|
+
}
|
|
2700
|
+
if (!routes[entry.standardPath]) {
|
|
2701
|
+
routes[entry.standardPath] = {};
|
|
2702
|
+
}
|
|
2703
|
+
if (!routes[entry.standardPath][handlerType]) {
|
|
2704
|
+
routes[entry.standardPath][handlerType] =
|
|
2705
|
+
{};
|
|
2706
|
+
}
|
|
2707
|
+
routes[entry.standardPath][handlerType][methodUpper] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return routes;
|
|
2713
|
+
}
|
|
2714
|
+
/**
|
|
2715
|
+
* Generates a routes object keyed by method then by pathname then by handler-type.
|
|
2716
|
+
*
|
|
2717
|
+
* @returns Routes object
|
|
2718
|
+
*/
|
|
2719
|
+
getRoutesByMethodThenPathname() {
|
|
2720
|
+
const routes = {};
|
|
2721
|
+
for (const handlerType of Object.keys(__classPrivateFieldGet(this, _Router_routes, "f"))) {
|
|
2722
|
+
const entry0 = __classPrivateFieldGet(this, _Router_routes, "f")[handlerType];
|
|
2723
|
+
for (const methodUpper of Object.keys(entry0)) {
|
|
2724
|
+
const entry1 = entry0[methodUpper];
|
|
2725
|
+
// super-globs
|
|
2726
|
+
for (const superGlobEntryIdx of entry1.superGlobsIndices) {
|
|
2727
|
+
const superGlobEntries = entry1.superGlobs[superGlobEntryIdx];
|
|
2728
|
+
for (const [, entry] of superGlobEntries) {
|
|
2729
|
+
if (!entry.pipe) {
|
|
2730
|
+
continue;
|
|
2731
|
+
}
|
|
2732
|
+
if (!routes[methodUpper]) {
|
|
2733
|
+
routes[methodUpper] = {};
|
|
2734
|
+
}
|
|
2735
|
+
if (!routes[methodUpper][entry.standardPath]) {
|
|
2736
|
+
routes[methodUpper][entry.standardPath] = {};
|
|
2737
|
+
}
|
|
2738
|
+
routes[methodUpper][entry.standardPath][handlerType] = Array.isArray(entry.pipe)
|
|
2739
|
+
? [...entry.pipe]
|
|
2740
|
+
: entry.pipe;
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
// globs
|
|
2744
|
+
for (const globEntryIdx of entry1.globsIndices) {
|
|
2745
|
+
const globEntries = entry1.globs[globEntryIdx];
|
|
2746
|
+
for (const [, entry] of globEntries) {
|
|
2747
|
+
if (!entry.pipe) {
|
|
2748
|
+
continue;
|
|
2749
|
+
}
|
|
2750
|
+
if (!routes[methodUpper]) {
|
|
2751
|
+
routes[methodUpper] = {};
|
|
2752
|
+
}
|
|
2753
|
+
if (!routes[methodUpper][entry.standardPath]) {
|
|
2754
|
+
routes[methodUpper][entry.standardPath] = {};
|
|
2755
|
+
}
|
|
2756
|
+
routes[methodUpper][entry.standardPath][handlerType] = Array.isArray(entry.pipe)
|
|
2757
|
+
? [...entry.pipe]
|
|
2758
|
+
: entry.pipe;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
// normal paths
|
|
2762
|
+
for (const entryIdx of entry1.entriesIndices) {
|
|
2763
|
+
const entries = entry1.entries[entryIdx];
|
|
2764
|
+
for (const [, entry] of entries) {
|
|
2765
|
+
if (!entry.pipe) {
|
|
2766
|
+
continue;
|
|
2767
|
+
}
|
|
2768
|
+
if (!routes[methodUpper]) {
|
|
2769
|
+
routes[methodUpper] = {};
|
|
2770
|
+
}
|
|
2771
|
+
if (!routes[methodUpper][entry.standardPath]) {
|
|
2772
|
+
routes[methodUpper][entry.standardPath] = {};
|
|
2773
|
+
}
|
|
2774
|
+
routes[methodUpper][entry.standardPath][handlerType] = Array.isArray(entry.pipe)
|
|
2775
|
+
? [...entry.pipe]
|
|
2776
|
+
: entry.pipe;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return routes;
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* Generates a routes object keyed by method then by handler-type then by pathname.
|
|
2785
|
+
*
|
|
2786
|
+
* @returns Routes object
|
|
2787
|
+
*/
|
|
2788
|
+
getRoutesByMethodThenHandlerType() {
|
|
2789
|
+
const routes = {};
|
|
2790
|
+
for (const handlerType of Object.keys(__classPrivateFieldGet(this, _Router_routes, "f"))) {
|
|
2791
|
+
const entry0 = __classPrivateFieldGet(this, _Router_routes, "f")[handlerType];
|
|
2792
|
+
for (const methodUpper of Object.keys(entry0)) {
|
|
2793
|
+
const entry1 = entry0[methodUpper];
|
|
2794
|
+
// super-globs
|
|
2795
|
+
for (const superGlobEntryIdx of entry1.superGlobsIndices) {
|
|
2796
|
+
const superGlobEntries = entry1.superGlobs[superGlobEntryIdx];
|
|
2797
|
+
for (const [, entry] of superGlobEntries) {
|
|
2798
|
+
if (!entry.pipe) {
|
|
2799
|
+
continue;
|
|
2800
|
+
}
|
|
2801
|
+
if (!routes[methodUpper]) {
|
|
2802
|
+
routes[methodUpper] = {};
|
|
2803
|
+
}
|
|
2804
|
+
if (!routes[methodUpper][handlerType]) {
|
|
2805
|
+
routes[methodUpper][handlerType] = {};
|
|
2806
|
+
}
|
|
2807
|
+
routes[methodUpper][handlerType][entry.standardPath] = Array.isArray(entry.pipe)
|
|
2808
|
+
? [...entry.pipe]
|
|
2809
|
+
: entry.pipe;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
// globs
|
|
2813
|
+
for (const globEntryIdx of entry1.globsIndices) {
|
|
2814
|
+
const globEntries = entry1.globs[globEntryIdx];
|
|
2815
|
+
for (const [, entry] of globEntries) {
|
|
2816
|
+
if (!entry.pipe) {
|
|
2817
|
+
continue;
|
|
2818
|
+
}
|
|
2819
|
+
if (!routes[methodUpper]) {
|
|
2820
|
+
routes[methodUpper] = {};
|
|
2821
|
+
}
|
|
2822
|
+
if (!routes[methodUpper][handlerType]) {
|
|
2823
|
+
routes[methodUpper][handlerType] = {};
|
|
2824
|
+
}
|
|
2825
|
+
routes[methodUpper][handlerType][entry.standardPath] = Array.isArray(entry.pipe)
|
|
2826
|
+
? [...entry.pipe]
|
|
2827
|
+
: entry.pipe;
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
// normal paths
|
|
2831
|
+
for (const entryIdx of entry1.entriesIndices) {
|
|
2832
|
+
const entries = entry1.entries[entryIdx];
|
|
2833
|
+
for (const [, entry] of entries) {
|
|
2834
|
+
if (!entry.pipe) {
|
|
2835
|
+
continue;
|
|
2836
|
+
}
|
|
2837
|
+
if (!routes[methodUpper]) {
|
|
2838
|
+
routes[methodUpper] = {};
|
|
2839
|
+
}
|
|
2840
|
+
if (!routes[methodUpper][handlerType]) {
|
|
2841
|
+
routes[methodUpper][handlerType] = {};
|
|
2842
|
+
}
|
|
2843
|
+
routes[methodUpper][handlerType][entry.standardPath] = Array.isArray(entry.pipe)
|
|
2844
|
+
? [...entry.pipe]
|
|
2845
|
+
: entry.pipe;
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
return routes;
|
|
2851
|
+
}
|
|
2852
|
+
/**
|
|
2853
|
+
* Generates a routes object keyed by handler-type then by method then by pathname.
|
|
2854
|
+
*
|
|
2855
|
+
* @returns Routes object
|
|
2856
|
+
*/
|
|
2857
|
+
getRoutesByHandlerTypeThenMethod() {
|
|
2858
|
+
const routes = {};
|
|
2859
|
+
for (const handlerType of Object.keys(__classPrivateFieldGet(this, _Router_routes, "f"))) {
|
|
2860
|
+
const entry0 = __classPrivateFieldGet(this, _Router_routes, "f")[handlerType];
|
|
2861
|
+
for (const methodUpper of Object.keys(entry0)) {
|
|
2862
|
+
const entry1 = entry0[methodUpper];
|
|
2863
|
+
// super-globs
|
|
2864
|
+
for (const superGlobEntryIdx of entry1.superGlobsIndices) {
|
|
2865
|
+
const superGlobEntries = entry1.superGlobs[superGlobEntryIdx];
|
|
2866
|
+
for (const [, entry] of superGlobEntries) {
|
|
2867
|
+
if (!entry.pipe) {
|
|
2868
|
+
continue;
|
|
2869
|
+
}
|
|
2870
|
+
if (!routes[handlerType]) {
|
|
2871
|
+
routes[handlerType] = {};
|
|
2872
|
+
}
|
|
2873
|
+
if (!routes[handlerType][methodUpper]) {
|
|
2874
|
+
routes[handlerType][methodUpper] = {};
|
|
2875
|
+
}
|
|
2876
|
+
routes[handlerType][methodUpper][entry.standardPath] = Array.isArray(entry.pipe)
|
|
2877
|
+
? [...entry.pipe]
|
|
2878
|
+
: entry.pipe;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
// globs
|
|
2882
|
+
for (const globEntryIdx of entry1.globsIndices) {
|
|
2883
|
+
const globEntries = entry1.globs[globEntryIdx];
|
|
2884
|
+
for (const [, entry] of globEntries) {
|
|
2885
|
+
if (!entry.pipe) {
|
|
2886
|
+
continue;
|
|
2887
|
+
}
|
|
2888
|
+
if (!routes[handlerType]) {
|
|
2889
|
+
routes[handlerType] = {};
|
|
2890
|
+
}
|
|
2891
|
+
if (!routes[handlerType][methodUpper]) {
|
|
2892
|
+
routes[handlerType][methodUpper] = {};
|
|
2893
|
+
}
|
|
2894
|
+
routes[handlerType][methodUpper][entry.standardPath] = Array.isArray(entry.pipe)
|
|
2895
|
+
? [...entry.pipe]
|
|
2896
|
+
: entry.pipe;
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
// normal paths
|
|
2900
|
+
for (const entryIdx of entry1.entriesIndices) {
|
|
2901
|
+
const entries = entry1.entries[entryIdx];
|
|
2902
|
+
for (const [, entry] of entries) {
|
|
2903
|
+
if (!entry.pipe) {
|
|
2904
|
+
continue;
|
|
2905
|
+
}
|
|
2906
|
+
if (!routes[handlerType]) {
|
|
2907
|
+
routes[handlerType] = {};
|
|
2908
|
+
}
|
|
2909
|
+
if (!routes[handlerType][methodUpper]) {
|
|
2910
|
+
routes[handlerType][methodUpper] = {};
|
|
2911
|
+
}
|
|
2912
|
+
routes[handlerType][methodUpper][entry.standardPath] = Array.isArray(entry.pipe)
|
|
2913
|
+
? [...entry.pipe]
|
|
2914
|
+
: entry.pipe;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
return routes;
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Generates a routes object keyed by handler-type then by pathname then by method.
|
|
2923
|
+
*
|
|
2924
|
+
* @returns Routes object
|
|
2925
|
+
*/
|
|
2926
|
+
getRoutesByHandlerTypeThenPathname() {
|
|
2927
|
+
const routes = {};
|
|
2928
|
+
for (const handlerType of Object.keys(__classPrivateFieldGet(this, _Router_routes, "f"))) {
|
|
2929
|
+
const entry0 = __classPrivateFieldGet(this, _Router_routes, "f")[handlerType];
|
|
2930
|
+
for (const methodUpper of Object.keys(entry0)) {
|
|
2931
|
+
const entry1 = entry0[methodUpper];
|
|
2932
|
+
// super-globs
|
|
2933
|
+
for (const superGlobEntryIdx of entry1.superGlobsIndices) {
|
|
2934
|
+
const superGlobEntries = entry1.superGlobs[superGlobEntryIdx];
|
|
2935
|
+
for (const [, entry] of superGlobEntries) {
|
|
2936
|
+
if (!entry.pipe) {
|
|
2937
|
+
continue;
|
|
2938
|
+
}
|
|
2939
|
+
if (!routes[handlerType]) {
|
|
2940
|
+
routes[handlerType] = {};
|
|
2941
|
+
}
|
|
2942
|
+
if (!routes[handlerType][entry.standardPath]) {
|
|
2943
|
+
routes[handlerType][entry.standardPath] =
|
|
2944
|
+
{};
|
|
2945
|
+
}
|
|
2946
|
+
routes[handlerType][entry.standardPath][methodUpper] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
// globs
|
|
2950
|
+
for (const globEntryIdx of entry1.globsIndices) {
|
|
2951
|
+
const globEntries = entry1.globs[globEntryIdx];
|
|
2952
|
+
for (const [, entry] of globEntries) {
|
|
2953
|
+
if (!entry.pipe) {
|
|
2954
|
+
continue;
|
|
2955
|
+
}
|
|
2956
|
+
if (!routes[handlerType]) {
|
|
2957
|
+
routes[handlerType] = {};
|
|
2958
|
+
}
|
|
2959
|
+
if (!routes[handlerType][entry.standardPath]) {
|
|
2960
|
+
routes[handlerType][entry.standardPath] =
|
|
2961
|
+
{};
|
|
2962
|
+
}
|
|
2963
|
+
routes[handlerType][entry.standardPath][methodUpper] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
// normal paths
|
|
2967
|
+
for (const entryIdx of entry1.entriesIndices) {
|
|
2968
|
+
const entries = entry1.entries[entryIdx];
|
|
2969
|
+
for (const [, entry] of entries) {
|
|
2970
|
+
if (!entry.pipe) {
|
|
2971
|
+
continue;
|
|
2972
|
+
}
|
|
2973
|
+
if (!routes[handlerType]) {
|
|
2974
|
+
routes[handlerType] = {};
|
|
2975
|
+
}
|
|
2976
|
+
if (!routes[handlerType][entry.standardPath]) {
|
|
2977
|
+
routes[handlerType][entry.standardPath] =
|
|
2978
|
+
{};
|
|
2979
|
+
}
|
|
2980
|
+
routes[handlerType][entry.standardPath][methodUpper] = Array.isArray(entry.pipe) ? [...entry.pipe] : entry.pipe;
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
return routes;
|
|
2986
|
+
}
|
|
2560
2987
|
}
|
|
2561
2988
|
exports.Router = Router;
|
|
2562
2989
|
_Router_config = new WeakMap(), _Router_routes = new WeakMap(), _Router_setters = new WeakMap(), _Router_instances = new WeakSet(), _Router_generateUniqueOperationId = function _Router_generateUniqueOperationId(method, path, clean, usedIds) {
|
|
@@ -2757,6 +3184,9 @@ _Router_config = new WeakMap(), _Router_routes = new WeakMap(), _Router_setters
|
|
|
2757
3184
|
entries: new Array(__classPrivateFieldGet(this, _Router_config, "f").maxPath + 1),
|
|
2758
3185
|
globs: new Array(__classPrivateFieldGet(this, _Router_config, "f").maxPath + 1),
|
|
2759
3186
|
superGlobs: new Array(__classPrivateFieldGet(this, _Router_config, "f").maxPath + 1),
|
|
3187
|
+
entriesIndices: [],
|
|
3188
|
+
globsIndices: [],
|
|
3189
|
+
superGlobsIndices: [],
|
|
2760
3190
|
};
|
|
2761
3191
|
}, _Router_initRoutes = function _Router_initRoutes() {
|
|
2762
3192
|
const routes = {};
|