moleculerjs / moleculer-web

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

REST shortcut doesn't handle action object correctly #344

Open thib3113 opened 7 months ago

thib3113 commented 7 months ago

The problem is here : https://github.com/moleculerjs/moleculer-web/blob/master/src/index.js#L1469

If I setup an alias like :

{
  "REST /users": {
    action : "action"
  }
}

it will treat the action as a string . But it's an object .

it's maybe better to just check if action is not a string ? ( or better if action is an object )

    if (typeof action === "object" && action.action) {
        if (action.only) {
            actions = actions.filter(item => action.only.includes(item));
        }

        if (action.except) {
            actions = actions.filter(item => !action.except.includes(item));
        }

        action = action.action;
    }