@nextrush/router 3.0.7 → 4.0.0-beta.1

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.
Files changed (51) hide show
  1. package/README.md +250 -492
  2. package/dist/index.d.ts +227 -178
  3. package/dist/index.js +1075 -657
  4. package/dist/index.js.map +1 -1
  5. package/package.json +7 -6
  6. package/src/__tests__/allowed-methods.test.ts +144 -0
  7. package/src/__tests__/audit-fixes.test.ts +59 -0
  8. package/src/__tests__/canonical-path-security.test.ts +198 -0
  9. package/src/__tests__/canonicalize-memo.test.ts +108 -0
  10. package/src/__tests__/dispatch-deasync.test.ts +292 -0
  11. package/src/__tests__/find-node-differential.test.ts +220 -0
  12. package/src/__tests__/fixtures/match-golden.json +556 -0
  13. package/src/__tests__/head-auto-registration.test.ts +197 -0
  14. package/src/__tests__/helpers/differential-corpus.ts +314 -0
  15. package/src/__tests__/match-differential.test.ts +46 -0
  16. package/src/__tests__/match-hotpath-guard.test.ts +71 -0
  17. package/src/__tests__/match-node-indexed-unpooled.test.ts +83 -0
  18. package/src/__tests__/match-normalize-fastpath.test.ts +64 -0
  19. package/src/__tests__/match-prenormalized.test.ts +95 -0
  20. package/src/__tests__/match-safety.test.ts +223 -0
  21. package/src/__tests__/match-single-alloc.test.ts +82 -0
  22. package/src/__tests__/match-walk-pool-safety.test.ts +103 -0
  23. package/src/__tests__/middleware-pipeline.test.ts +306 -0
  24. package/src/__tests__/param-decoding.test.ts +78 -0
  25. package/src/__tests__/public-surface.test.ts +72 -0
  26. package/src/__tests__/registration-max-depth.test.ts +56 -0
  27. package/src/__tests__/route-metadata.test.ts +172 -0
  28. package/src/__tests__/router-audit.test.ts +315 -0
  29. package/src/__tests__/router-edge-cases.test.ts +2 -7
  30. package/src/__tests__/router.test.ts +148 -7
  31. package/src/__tests__/static-map-reset.test.ts +48 -0
  32. package/src/__tests__/walk-pool-sizing.test.ts +72 -0
  33. package/src/__tests__/walk-pool-undersized-guard.test.ts +59 -0
  34. package/src/canonicalize.ts +137 -0
  35. package/src/composition.ts +79 -0
  36. package/src/constants.ts +43 -0
  37. package/src/dispatch.ts +145 -0
  38. package/src/find-node.ts +125 -0
  39. package/src/group-router.ts +208 -0
  40. package/src/index.ts +14 -5
  41. package/src/match-route.ts +241 -0
  42. package/src/matching.ts +246 -0
  43. package/src/middleware-adapter.ts +59 -0
  44. package/src/redirect.ts +97 -0
  45. package/src/registration.ts +343 -0
  46. package/src/route-metadata.ts +68 -0
  47. package/src/router.ts +219 -872
  48. package/src/segment-trie.ts +227 -0
  49. package/src/state.ts +53 -0
  50. package/src/walk-pool.ts +208 -0
  51. package/src/radix-tree.ts +0 -184
@@ -0,0 +1,556 @@
1
+ {
2
+ "default GET /": {
3
+ "matched": true,
4
+ "handlerTag": "root",
5
+ "params": [],
6
+ "hasExecutor": true
7
+ },
8
+ "default GET /users": {
9
+ "matched": true,
10
+ "handlerTag": "users",
11
+ "params": [],
12
+ "hasExecutor": true
13
+ },
14
+ "default GET /users/": {
15
+ "matched": true,
16
+ "handlerTag": "users",
17
+ "params": [],
18
+ "hasExecutor": true
19
+ },
20
+ "default GET /users/me": {
21
+ "matched": true,
22
+ "handlerTag": "users.me",
23
+ "params": [],
24
+ "hasExecutor": true
25
+ },
26
+ "default GET /users/42": {
27
+ "matched": true,
28
+ "handlerTag": "users.id",
29
+ "params": [
30
+ [
31
+ "id",
32
+ "42"
33
+ ]
34
+ ],
35
+ "hasExecutor": true
36
+ },
37
+ "default GET /users/42/": {
38
+ "matched": true,
39
+ "handlerTag": "users.id",
40
+ "params": [
41
+ [
42
+ "id",
43
+ "42"
44
+ ]
45
+ ],
46
+ "hasExecutor": true
47
+ },
48
+ "default GET /Users/AbC": {
49
+ "matched": true,
50
+ "handlerTag": "users.id",
51
+ "params": [
52
+ [
53
+ "id",
54
+ "AbC"
55
+ ]
56
+ ],
57
+ "hasExecutor": true
58
+ },
59
+ "default GET /users/a%20b": {
60
+ "matched": true,
61
+ "handlerTag": "users.id",
62
+ "params": [
63
+ [
64
+ "id",
65
+ "a b"
66
+ ]
67
+ ],
68
+ "hasExecutor": true
69
+ },
70
+ "default GET /users/a%2Fb": {
71
+ "matched": true,
72
+ "handlerTag": "users.id",
73
+ "params": [
74
+ [
75
+ "id",
76
+ "a/b"
77
+ ]
78
+ ],
79
+ "hasExecutor": true
80
+ },
81
+ "default GET /users/a%2Eb": {
82
+ "matched": true,
83
+ "handlerTag": "users.id",
84
+ "params": [
85
+ [
86
+ "id",
87
+ "a.b"
88
+ ]
89
+ ],
90
+ "hasExecutor": true
91
+ },
92
+ "default GET /users/%zz": {
93
+ "matched": true,
94
+ "handlerTag": "users.id",
95
+ "params": [
96
+ [
97
+ "id",
98
+ "%zz"
99
+ ]
100
+ ],
101
+ "hasExecutor": true
102
+ },
103
+ "default GET /users/%": {
104
+ "matched": true,
105
+ "handlerTag": "users.id",
106
+ "params": [
107
+ [
108
+ "id",
109
+ "%"
110
+ ]
111
+ ],
112
+ "hasExecutor": true
113
+ },
114
+ "default GET /users/%2": {
115
+ "matched": true,
116
+ "handlerTag": "users.id",
117
+ "params": [
118
+ [
119
+ "id",
120
+ "%2"
121
+ ]
122
+ ],
123
+ "hasExecutor": true
124
+ },
125
+ "default GET /users/Ürl": {
126
+ "matched": true,
127
+ "handlerTag": "users.id",
128
+ "params": [
129
+ [
130
+ "id",
131
+ "Ürl"
132
+ ]
133
+ ],
134
+ "hasExecutor": true
135
+ },
136
+ "default GET /a/b/c": {
137
+ "matched": true,
138
+ "handlerTag": "a.b.c",
139
+ "params": [],
140
+ "hasExecutor": true
141
+ },
142
+ "default GET /a/b/c/": {
143
+ "matched": true,
144
+ "handlerTag": "a.b.c",
145
+ "params": [],
146
+ "hasExecutor": true
147
+ },
148
+ "default GET /a/b/d": {
149
+ "matched": true,
150
+ "handlerTag": "a.b.d",
151
+ "params": [],
152
+ "hasExecutor": true
153
+ },
154
+ "default GET /a/b/x": {
155
+ "matched": false,
156
+ "handlerTag": null,
157
+ "params": [],
158
+ "hasExecutor": false
159
+ },
160
+ "default GET /a/1/b/2": {
161
+ "matched": true,
162
+ "handlerTag": "a.x.b.y",
163
+ "params": [
164
+ [
165
+ "x",
166
+ "1"
167
+ ],
168
+ [
169
+ "y",
170
+ "2"
171
+ ]
172
+ ],
173
+ "hasExecutor": true
174
+ },
175
+ "default GET /p/me": {
176
+ "matched": true,
177
+ "handlerTag": "p.me",
178
+ "params": [],
179
+ "hasExecutor": true
180
+ },
181
+ "default GET /p/other": {
182
+ "matched": true,
183
+ "handlerTag": "p.id",
184
+ "params": [
185
+ [
186
+ "id",
187
+ "other"
188
+ ]
189
+ ],
190
+ "hasExecutor": true
191
+ },
192
+ "default GET /p/a/b/c": {
193
+ "matched": true,
194
+ "handlerTag": "p.star",
195
+ "params": [
196
+ [
197
+ "*",
198
+ "a/b/c"
199
+ ]
200
+ ],
201
+ "hasExecutor": true
202
+ },
203
+ "default GET /files/A/b/c": {
204
+ "matched": true,
205
+ "handlerTag": "files.star",
206
+ "params": [
207
+ [
208
+ "*",
209
+ "A/b/c"
210
+ ]
211
+ ],
212
+ "hasExecutor": true
213
+ },
214
+ "default GET /files": {
215
+ "matched": false,
216
+ "handlerTag": null,
217
+ "params": [],
218
+ "hasExecutor": false
219
+ },
220
+ "default GET /files/": {
221
+ "matched": false,
222
+ "handlerTag": null,
223
+ "params": [],
224
+ "hasExecutor": false
225
+ },
226
+ "default GET /g/1/b/c": {
227
+ "matched": true,
228
+ "handlerTag": "g.x.star",
229
+ "params": [
230
+ [
231
+ "*",
232
+ "b/c"
233
+ ],
234
+ [
235
+ "x",
236
+ "1"
237
+ ]
238
+ ],
239
+ "hasExecutor": true
240
+ },
241
+ "default GET /users?q=1": {
242
+ "matched": true,
243
+ "handlerTag": "users",
244
+ "params": [],
245
+ "hasExecutor": true
246
+ },
247
+ "default GET /users/42?x=y": {
248
+ "matched": true,
249
+ "handlerTag": "users.id",
250
+ "params": [
251
+ [
252
+ "id",
253
+ "42"
254
+ ]
255
+ ],
256
+ "hasExecutor": true
257
+ },
258
+ "default GET //a//b//c": {
259
+ "matched": true,
260
+ "handlerTag": "a.b.c",
261
+ "params": [],
262
+ "hasExecutor": true
263
+ },
264
+ "default GET ///": {
265
+ "matched": true,
266
+ "handlerTag": "root",
267
+ "params": [],
268
+ "hasExecutor": true
269
+ },
270
+ "default GET /nope": {
271
+ "matched": false,
272
+ "handlerTag": null,
273
+ "params": [],
274
+ "hasExecutor": false
275
+ },
276
+ "default POST /users": {
277
+ "matched": true,
278
+ "handlerTag": "users.post",
279
+ "params": [],
280
+ "hasExecutor": true
281
+ },
282
+ "default POST /users/me": {
283
+ "matched": false,
284
+ "handlerTag": null,
285
+ "params": [],
286
+ "hasExecutor": false
287
+ },
288
+ "default DELETE /users/42": {
289
+ "matched": false,
290
+ "handlerTag": null,
291
+ "params": [],
292
+ "hasExecutor": false
293
+ },
294
+ "default GET /deep/s0/s1/s2/s3/s4/s5/s6/s7/s8/s9/s10/s11/s12/s13/s14/s15/s16/s17/s18/s19/s20/s21/s22/s23/s24/s25/s26/s27/s28/s29/s30/s31/s32/s33/s34/s35/s36/s37/s38/s39/s40/s41/s42/s43/s44/s45/s46/s47/s48/s49/s50/s51/s52/s53/s54/s55/s56/s57/s58/s59/s60/s61/s62/s63/s64/s65/s66/s67/s68/s69/s70/s71/s72/s73/s74/s75/s76/s77/s78/s79/s80/s81/s82/s83/s84/s85/s86/s87/s88/s89/s90/s91/s92/s93/s94/s95/s96/s97/s98/s99/s100/s101/s102/s103/s104/s105/s106/s107/s108/s109/s110/s111/s112/s113/s114/s115/s116/s117/s118/s119/s120/s121/s122/s123/s124/s125/s126/s127/s128/s129/s130/s131/s132/s133/s134/s135/s136/s137/s138/s139/s140/s141/s142/s143/s144/s145/s146/s147/s148/s149/s150/s151/s152/s153/s154/s155/s156/s157/s158/s159/s160/s161/s162/s163/s164/s165/s166/s167/s168/s169/s170/s171/s172/s173/s174/s175/s176/s177/s178/s179/s180/s181/s182/s183/s184/s185/s186/s187/s188/s189/s190/s191/s192/s193/s194/s195/s196/s197/s198/s199": {
295
+ "matched": false,
296
+ "handlerTag": null,
297
+ "params": [],
298
+ "hasExecutor": false
299
+ },
300
+ "caseSensitive GET /Users/AbC": {
301
+ "matched": true,
302
+ "handlerTag": "cs.users.id",
303
+ "params": [
304
+ [
305
+ "id",
306
+ "AbC"
307
+ ]
308
+ ],
309
+ "hasExecutor": true
310
+ },
311
+ "caseSensitive GET /users/abc": {
312
+ "matched": false,
313
+ "handlerTag": null,
314
+ "params": [],
315
+ "hasExecutor": false
316
+ },
317
+ "caseSensitive GET /Static": {
318
+ "matched": true,
319
+ "handlerTag": "cs.static",
320
+ "params": [],
321
+ "hasExecutor": true
322
+ },
323
+ "caseSensitive GET /static": {
324
+ "matched": false,
325
+ "handlerTag": null,
326
+ "params": [],
327
+ "hasExecutor": false
328
+ },
329
+ "strict GET /strict": {
330
+ "matched": true,
331
+ "handlerTag": "strict.static",
332
+ "params": [],
333
+ "hasExecutor": true
334
+ },
335
+ "strict GET /strict/": {
336
+ "matched": true,
337
+ "handlerTag": "strict.static",
338
+ "params": [],
339
+ "hasExecutor": true
340
+ },
341
+ "strict GET /strict/42": {
342
+ "matched": true,
343
+ "handlerTag": "strict.id",
344
+ "params": [
345
+ [
346
+ "id",
347
+ "42"
348
+ ]
349
+ ],
350
+ "hasExecutor": true
351
+ },
352
+ "strict GET /strict/42/": {
353
+ "matched": true,
354
+ "handlerTag": "strict.id",
355
+ "params": [
356
+ [
357
+ "id",
358
+ "42"
359
+ ]
360
+ ],
361
+ "hasExecutor": true
362
+ },
363
+ "decodeOff GET /raw/a%20b": {
364
+ "matched": true,
365
+ "handlerTag": "raw.id",
366
+ "params": [
367
+ [
368
+ "id",
369
+ "a%20b"
370
+ ]
371
+ ],
372
+ "hasExecutor": true
373
+ },
374
+ "decodeOff GET /raw/a%2Fb": {
375
+ "matched": true,
376
+ "handlerTag": "raw.id",
377
+ "params": [
378
+ [
379
+ "id",
380
+ "a%2Fb"
381
+ ]
382
+ ],
383
+ "hasExecutor": true
384
+ },
385
+ "decodeOff GET /raw/x/y/z": {
386
+ "matched": true,
387
+ "handlerTag": "raw.star",
388
+ "params": [
389
+ [
390
+ "*",
391
+ "x/y/z"
392
+ ]
393
+ ],
394
+ "hasExecutor": true
395
+ },
396
+ "all GET /any": {
397
+ "matched": true,
398
+ "handlerTag": "any",
399
+ "params": [],
400
+ "hasExecutor": true
401
+ },
402
+ "all POST /any": {
403
+ "matched": true,
404
+ "handlerTag": "any",
405
+ "params": [],
406
+ "hasExecutor": true
407
+ },
408
+ "all PUT /any": {
409
+ "matched": true,
410
+ "handlerTag": "any",
411
+ "params": [],
412
+ "hasExecutor": true
413
+ },
414
+ "all DELETE /any": {
415
+ "matched": true,
416
+ "handlerTag": "any",
417
+ "params": [],
418
+ "hasExecutor": true
419
+ },
420
+ "all PATCH /any": {
421
+ "matched": true,
422
+ "handlerTag": "any",
423
+ "params": [],
424
+ "hasExecutor": true
425
+ },
426
+ "all HEAD /any": {
427
+ "matched": true,
428
+ "handlerTag": "any",
429
+ "params": [],
430
+ "hasExecutor": true
431
+ },
432
+ "all OPTIONS /any": {
433
+ "matched": true,
434
+ "handlerTag": "any",
435
+ "params": [],
436
+ "hasExecutor": true
437
+ },
438
+ "prefix GET /api/health": {
439
+ "matched": true,
440
+ "handlerTag": "api.health",
441
+ "params": [],
442
+ "hasExecutor": true
443
+ },
444
+ "prefix GET /health": {
445
+ "matched": false,
446
+ "handlerTag": null,
447
+ "params": [],
448
+ "hasExecutor": false
449
+ },
450
+ "prefix GET /api/items/7": {
451
+ "matched": true,
452
+ "handlerTag": "api.items.id",
453
+ "params": [
454
+ [
455
+ "id",
456
+ "7"
457
+ ]
458
+ ],
459
+ "hasExecutor": true
460
+ },
461
+ "mount GET /sub/x": {
462
+ "matched": true,
463
+ "handlerTag": "mount.x",
464
+ "params": [],
465
+ "hasExecutor": true
466
+ },
467
+ "mount GET /sub/other": {
468
+ "matched": true,
469
+ "handlerTag": "mount.p",
470
+ "params": [
471
+ [
472
+ "p",
473
+ "other"
474
+ ]
475
+ ],
476
+ "hasExecutor": true
477
+ },
478
+ "group GET /g/y": {
479
+ "matched": true,
480
+ "handlerTag": "group.y",
481
+ "params": [],
482
+ "hasExecutor": true
483
+ },
484
+ "group GET /g/other": {
485
+ "matched": true,
486
+ "handlerTag": "group.z",
487
+ "params": [
488
+ [
489
+ "z",
490
+ "other"
491
+ ]
492
+ ],
493
+ "hasExecutor": true
494
+ },
495
+ "backtrack GET /bt/b/c": {
496
+ "matched": true,
497
+ "handlerTag": "bt.x.c",
498
+ "params": [
499
+ [
500
+ "x",
501
+ "b"
502
+ ]
503
+ ],
504
+ "hasExecutor": true
505
+ },
506
+ "backtrack GET /bt/b/d": {
507
+ "matched": true,
508
+ "handlerTag": "bt.b.d",
509
+ "params": [],
510
+ "hasExecutor": true
511
+ },
512
+ "backtrack GET /bt/z/c": {
513
+ "matched": true,
514
+ "handlerTag": "bt.x.c",
515
+ "params": [
516
+ [
517
+ "x",
518
+ "z"
519
+ ]
520
+ ],
521
+ "hasExecutor": true
522
+ },
523
+ "backtrack GET /w/foo/other": {
524
+ "matched": true,
525
+ "handlerTag": "w.star",
526
+ "params": [
527
+ [
528
+ "*",
529
+ "foo/other"
530
+ ]
531
+ ],
532
+ "hasExecutor": true
533
+ },
534
+ "backtrack GET /w/foo/deep": {
535
+ "matched": true,
536
+ "handlerTag": "w.x.deep",
537
+ "params": [
538
+ [
539
+ "x",
540
+ "foo"
541
+ ]
542
+ ],
543
+ "hasExecutor": true
544
+ },
545
+ "backtrack GET /w/a/b/c": {
546
+ "matched": true,
547
+ "handlerTag": "w.star",
548
+ "params": [
549
+ [
550
+ "*",
551
+ "a/b/c"
552
+ ]
553
+ ],
554
+ "hasExecutor": true
555
+ }
556
+ }