-
-
Notifications
You must be signed in to change notification settings - Fork 461
Description
What is the problem this feature would solve?
In Macro v2, there is currently no way to inspect which routes have which macros applied, or what options those macros were configured with, at boot time. This prevents developers from performing tasks that depend on route introspection before handling requests, such as authorization auditing, documentation generation, and static security verification.
In Macro v1, this was possible due to undocumented behavior where macro options were stored in events.local and accessible through route.hooks during application initialization. That behavior no longer exists in Macro v2, making these workflows impossible without runtime access.
A detailed comparison of this difference can be found here:
https://github.com/hunterwilhelm/elysia-macro-v1-vs-v2
What is the feature you are proposing to solve the problem?
Add a supported way in Macro v2 to access macro configuration data at boot time. This could be achieved by:
Exposing applied macro metadata (such as options or identifiers) through route.hooks, or
Providing a dedicated introspection API (for example, via app.routes), or
Introducing an optional macro lifecycle hook like onRegister, allowing macros to register or expose their configuration when routes are defined.
Any of these approaches would restore the ability to audit, document, and analyze route configurations during startup.
What alternatives have you considered?
Currently, the only alternative is to manually track macro configurations within custom data stores or global variables inside each macro definition. This approach is error-prone, inconsistent, and difficult to maintain across large applications.
Having an official mechanism for boot-time macro introspection would provide a reliable and standardized way to support these workflows, similar to what was implicitly available in Macro v1.