0

Is there a way to add parameters on a moleculer-web route path? I would like to add a parameter in the path to avoid to add in each alias.

I have tried to add a parameter, but after that, I could not reach the endpoint anymore

broker.createService({
    mixins: [ApiService],
    settings: {
        routes: [
            {
                path: "/lng/:lng",
                aliases: {
                    "GET /secret": [
                        auth.isAuthenticated(),
                        auth.hasRole("admin"),
                        "top.secret"
                    ]
                }
            }
        ]
    }
});

Thanks

aquilesb
  • 2,182
  • 1
  • 19
  • 19

1 Answers1

2

No, you can use params in aliases only:

broker.createService({
  mixins: [ApiService],
  settings: {
    routes: [{
      path: "/lng",
      aliases: {
        "GET /:lng/secret": [
          auth.isAuthenticated(),
          auth.hasRole("admin"),
          "top.secret"
        ]
      }
    }]
  }
});
Icebob
  • 1,132
  • 7
  • 14