moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 118 forks source link

Alias doesn't work #239

Closed JulianXin216 closed 3 years ago

JulianXin216 commented 3 years ago

I am learning to use moleculer. I set the aliaes ine the routes setting .

 routes:[{
         path: "/api",
    whitelist: ["**"],
    aliases:{
        "abc":"status.systems",
        "count": "basic.count"
    },
    autoAliases: true
}]

But the address http://localhost:3010/api/abc got an error;

{
    "name": "ServiceNotFoundError",
    "message": "Service 'abc' is not found.",
    "code": 404,
    "type": "SERVICE_NOT_FOUND",
    "data": {
        "action": "abc"
    }
}.

I did somthing wrong?

I used VSCode to debug.

moleculer version:0.14.11 moleculer-web version:0.9.1

AndreMaz commented 3 years ago

The ServiceNotFoundError means that the service actions is not registered.

You can use moleculer-repl to see what actions are available/exposed.

intech commented 3 years ago

Does the service have a version? Then you need to specify it at the beginning of the service name

    aliases:{
        "abc":"v1.status.systems",
        "count": "v1.basic.count"
    },
JulianXin216 commented 3 years ago

Does the service have a version? Then you need to specify it at the beginning of the service name

  aliases:{
      "abc":"v1.status.systems",
      "count": "v1.basic.count"
  },

No version. After I cleaned the node_modules and reinstalled the modules. It works now. Maybe something wrong with my computer.