@emeryld/rrroutes-server 2.6.6 → 2.6.7

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.cjs CHANGED
@@ -591,6 +591,19 @@ function findShadowingPriorRoute(entries, method, path) {
591
591
  return routePatternMatchesConcretePath(entry.path, probePath);
592
592
  });
593
593
  }
594
+ function formatRouteShadowWarning(args) {
595
+ const { method, path, currentOrigin, prior } = args;
596
+ const newRoute = `${method} ${path}`;
597
+ const priorRoute = `${prior.method} ${prior.path}`;
598
+ return [
599
+ "[rrroutes-server][route-shadow-warning]",
600
+ ` New route: ${newRoute}`,
601
+ ` Existing route: ${priorRoute}`,
602
+ ` Precedence: ${priorRoute} takes precedence (registered first)`,
603
+ ` New origin: ${currentOrigin}`,
604
+ ` Existing origin: ${prior.origin}`
605
+ ].join("\n");
606
+ }
594
607
  function collectRoutesFromStack(appOrRouter) {
595
608
  const result = [];
596
609
  const stack = appOrRouter.stack ?? (appOrRouter._router ? appOrRouter._router.stack : void 0) ?? [];
@@ -674,7 +687,12 @@ function createRRRoute(router, config) {
674
687
  const shadowingEntry = findShadowingPriorRoute(registeredEntries, methodUpper, path);
675
688
  if (shadowingEntry) {
676
689
  console.warn(
677
- `[rrroutes-server] Registering ${methodUpper} ${path} may be shadowed by previously registered ${shadowingEntry.method} ${shadowingEntry.path}. Precedence: ${shadowingEntry.method} ${shadowingEntry.path} takes precedence (registered first). Current declaration origin: ${origin}. Prior declaration origin: ${shadowingEntry.origin}.`
690
+ formatRouteShadowWarning({
691
+ method: methodUpper,
692
+ path,
693
+ currentOrigin: origin,
694
+ prior: shadowingEntry
695
+ })
678
696
  );
679
697
  }
680
698
  emit({ type: "register", method: methodUpper, path });