0

I use custom mixins, which have internal actions.

I use middlewares over my own actions.

But actions of mixins fall into middlewares.

Need to use some duck typing check for ignoring mixin actions in middlewares.

Example for moleculer-io:

if (action.name === 'io.call') {
  return next(ctx);
}

Is exist more safe and robust way to check mixin action in middleware?

darky
  • 163
  • 1
  • 7

1 Answers1

1

The better way is that using a custom property in action definition and checking it in middleware.

In mixins:

actions: {
    find: {
        myFeature: true,
        handler(ctx) {}
    }   
}

In middleware:

{
    localCall(next, action) {
        if (action.myFeature) {
            // ...
        }

        return next;
    }
}
Icebob
  • 1,132
  • 7
  • 14