moleculer-web icon indicating copy to clipboard operation
moleculer-web copied to clipboard

Feature Request: Add listAllMappings action to expose both aliases and dynamic whitelist routes

Open JS-AK opened this issue 5 months ago • 0 comments

Current Limitation The current listAliases action only returns endpoints that are explicitly stored in the internal this.aliases array. This works fine for:

  1. Explicitly defined aliases.
  2. Auto-generated aliases (when autoAliases: true).

However, it completely ignores routes configured with autoAliases: false and a whitelist (where mappingPolicy defaults to 'all'). In these cases, the Gateway resolves requests dynamically at runtime, but listAliases returns nothing for them because no static alias objects exist in memory.

The Problem Because listAliases is missing these dynamically mapped endpoints, tools that rely on introspection to generate documentation (e.g., OpenAPI generators) produce incomplete results. They cannot "see" actions that are effectively public but allowed only via a whitelist.

Proposed Solution Implement a new internal action called listAllMappings.

This action should:

  1. Include all results that listAliases currently returns.
  2. Additionally iterate through all routes with mappingPolicy: 'all'.
  3. For these routes, scan the Service Broker's action registry, apply the route's whitelist/blacklist logic, and calculate the resulting endpoint paths on the fly.
  4. Return a comprehensive list of every callable endpoint on the Gateway.

Example Configuration that is currently "invisible":

{
    path: "/api",
    autoAliases: false,
    whitelist: [
        "users.list",
        "posts.*"
    ]
}

Current listAliases: Returns []. Proposed listAllMappings: Should return entries for users.list, posts.find, posts.get, etc.

https://github.com/moleculerjs/moleculer-web/pull/367

JS-AK avatar Dec 01 '25 08:12 JS-AK