holidayextras / jsonapi-server

A config driven NodeJS framework implementing json:api and GraphQL
MIT License
488 stars 115 forks source link

Right way, if any, to break/shortcircuit a chain handler and return earlier. #431

Open twss opened 5 years ago

twss commented 5 years ago

Given I have a chain handler:

chainHandler1.chain(chainHandler2).chain(memoryHandler)

and the normal flow would be:

chainHandler1.beforeSearch
  chainHandler2.beforeSearch
    MemoryHandler.search
  chainHandler2.afterSearch
chainHandler1.afterSearch

What would be the correct way to terminate early and only do:

chainHandler1.beforeSearch
chainHandler1.afterSearch