@agentcash/router 0.2.1 → 0.2.2

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
@@ -84,9 +84,15 @@ module.exports = __toCommonJS(index_exports);
84
84
  // src/registry.ts
85
85
  var RouteRegistry = class {
86
86
  routes = /* @__PURE__ */ new Map();
87
+ // Silently overwrites on duplicate key. Next.js module loading order is
88
+ // non-deterministic during build — discovery stubs and real handlers may
89
+ // register the same route key in either order. Last writer wins.
90
+ // Prior art: ElysiaJS uses the same pattern (silent overwrite in router.history).
87
91
  register(entry) {
88
- if (this.routes.has(entry.key)) {
89
- throw new Error(`route '${entry.key}': already registered (duplicate route key)`);
92
+ if (this.routes.has(entry.key) && typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production") {
93
+ console.warn(
94
+ `[agentcash/router] route '${entry.key}' registered twice \u2014 overwriting (this is expected for discovery stubs during next build)`
95
+ );
90
96
  }
91
97
  this.routes.set(entry.key, entry);
92
98
  }
package/dist/index.js CHANGED
@@ -50,9 +50,15 @@ var init_server = __esm({
50
50
  // src/registry.ts
51
51
  var RouteRegistry = class {
52
52
  routes = /* @__PURE__ */ new Map();
53
+ // Silently overwrites on duplicate key. Next.js module loading order is
54
+ // non-deterministic during build — discovery stubs and real handlers may
55
+ // register the same route key in either order. Last writer wins.
56
+ // Prior art: ElysiaJS uses the same pattern (silent overwrite in router.history).
53
57
  register(entry) {
54
- if (this.routes.has(entry.key)) {
55
- throw new Error(`route '${entry.key}': already registered (duplicate route key)`);
58
+ if (this.routes.has(entry.key) && typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production") {
59
+ console.warn(
60
+ `[agentcash/router] route '${entry.key}' registered twice \u2014 overwriting (this is expected for discovery stubs during next build)`
61
+ );
56
62
  }
57
63
  this.routes.set(entry.key, entry);
58
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentcash/router",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Unified route builder for Next.js App Router APIs with x402, MPP, SIWX, and API key auth",
5
5
  "type": "module",
6
6
  "exports": {