Skip to content

feat(routes): expose complete registered route handlers - #16

Merged
Upd4ting merged 6 commits into
mainfrom
fix/observable-registered-routes
Aug 27, 2026
Merged

feat(routes): expose complete registered route handlers#16
Upd4ting merged 6 commits into
mainfrom
fix/observable-registered-routes

Conversation

@Upd4ting

@Upd4ting Upd4ting commented Aug 21, 2026

Copy link
Copy Markdown
Member

Summary

  • expose getRegisteredRouteHandlers() as a snapshot of the complete route registry
  • return each route id with its full RouteHandler, including mode, callback, prototype, parameters, properties, priority, and owner module
  • rely on the existing routesList lifecycle so explicit unregister and module unload remove stale entries
  • leave the real routesProxy provider attachment untouched

Why

CMS API needs complete handlers for route introspection, middleware ordering, controller inspection, and request-log matching. The existing getRegisteredRoutes() intentionally returns reduced metadata and omits mode, the callback, and the controller prototype.

CMS API currently works around that limitation by calling the internal routesProxy.onRegister() and onUnregister() methods. Those methods attach the real API implementation; they are not a multicast event source. A second attachment can replace or compete with the API provider.

The new getter exposes the already-maintained source of truth directly. CMS API #22 can remove its mirrored cache and read the current registry without subscriptions, replay, detach logic, or provider interaction.

Contract

  • every call returns a new array snapshot
  • each handler is the same complete handler object sent to the API provider
  • explicitly unregistered routes are absent
  • routes removed during module unload are absent
  • no observer or callback is installed

Validation

  • pnpm lint
  • pnpm build
  • pnpm --package=@antelopejs/core@1.4.7 dlx ajs module test . — 83 passing
  • generated declaration inspection
  • pnpm pack and packed declaration inspection
  • git diff --check

The planned release is 0.0.13; this PR intentionally does not bump the package version.

Expose a replayable multicast lifecycle API for complete route handlers without attaching another provider to the internal registering proxy. Keep explicit removals and module unloads synchronized with the public observer.
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Snapshot live subscribers so nested subscriptions do not receive duplicate events. Skip stale replay entries removed by earlier observer callbacks.

Copy link
Copy Markdown
Member Author

@greptile review

Comment thread src/index.ts Outdated
Track observer subscription generations so callbacks removed during an emission are skipped, including remove-and-resubscribe sequences.

Copy link
Copy Markdown
Member Author

@greptile review

Revalidate the route before each live registration callback so reentrant removal cannot leave later observer caches stale.

Copy link
Copy Markdown
Member Author

@greptile review

Comment thread src/index.ts Outdated
Reuse one active subscription per observer identity so either unsubscribe handle stops future notifications without weakening reentrant generation checks.

Copy link
Copy Markdown
Member Author

@greptile review

Co-authored-by: Upd4ting <upd4ting@gmail.com>
@Upd4ting Upd4ting changed the title feat(routes): add registered route lifecycle observer feat(routes): expose complete registered route handlers Aug 27, 2026
@Upd4ting
Upd4ting merged commit d7cdfd4 into main Aug 27, 2026
2 checks passed
@Upd4ting
Upd4ting deleted the fix/observable-registered-routes branch August 27, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants