medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Feat(medusa): First interceptor pattern proposal

Open adrien2p opened this issue 3 years ago • 1 comments

What

In some cases, it make sense to be able to manipulate or do some action before reaching an end point, and it goes the same to intercept a response and manipulate or do some actions before being sent to the client. It can be simple or complex cases and it can be a good thing to be able to separate that logic from the handler to keep the responsibility clean but close together.

How

A new function useInterceptors is proposed, as well as an abstract Interceptor that can be extender to build an interceptor, it will manage the interception of both input/output and take an array of interceptors as a parameter and will manage to call the before and after of each of them.

adrien2p avatar Jul 01 '22 07:07 adrien2p

⚠️ No Changeset found

Latest commit: f38b6dc1e202f733a627427537bb2468da7c7ba1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 01 '22 07:07 changeset-bot[bot]