axa-group / bauta.js

Bauta.js is an add-on for your Node.js applications such as Express.js or Fastify.
Other
42 stars 3 forks source link

tap decorator must support async Step #27

Closed franher closed 2 years ago

franher commented 2 years ago

The current implementation of the Bauta.js tap decorator does not support Step functions returning a Promise.

We want to do something like this:

const { tap, step, pipe } require('@axa/bautajs-core');

const randomPreviousPipeline = step(() => 'I am so random!');

const pipeline = pipe(
 randomPreviousPipeline,
 tap(async (prev) => {
   return 'The promise will be resolved with this message!';
 }),
 (prev) => {
   console.log(prev);
   // print 'I am so random!'
 }
);

The management done on the pairwise decorator could be used as the base of the new implementation for the tap decorator improvement .