List moleculer http entry points

194 views Asked by At

I'm using moleculer-web, how can I get a list of API URLs available.

http://0.0.0.0:4000/~node/actions shows 404.

1

There are 1 answers

1
Ivan Zhuravlev On BEST ANSWER

The ~ sign is used for internal services referenced by $node.actions and by default these paths are not available. To make an internal service available, you must specify:

    broker.createService ({
        mixins: [ApiService],
        settings: {
            routes: [{
                path: "/",
                whitelist: ["$node.*"]
            }]
        }
    });

At the same time, the answer to your question about receiving all routes cannot be retrieved. Action are registered actions within services. And URLs are routes and aliases for services, they are stored in one api service locally and in order to get them you will need to do the conversion to the desired form.

    broker.createService ({
        mixins: [ApiService],
        settings: {
            routes: [{
                path: "/",
                aliases: {
                    "GET aliases": "api.listAliases",
                },
                mappingPolicy: "all"
            }]
        }
    });

GET /aliases print response json Example

[{"actionName":"api.listAliases","path":"aliases","fullPath":"/aliases","methods":"GET","routePath":"/"}]

Write if you need to disclose this in more detail.