Adaptor to adapt (hooked) action function to express standard middleware/handler function signature.
(Object
= {}
)
Config
Name | Description |
---|---|
options.param Function?
(default req=>req.body )
|
Config on what variables passed to param |
options.meta Function?
(default req=>req.meta )
|
Config on what variables passed to meta |
options.context Function?
(default ()=>{} )
|
Config on what variables passed to context, besides the default req, res, next |
any
:
the original result of the action function
A decorator to use context.metrics to count error thrown from action.
A decorator to add conditional side-effect before error being thrown e.g. It can be used together with error-metrics to create conditional error-metrics e.g. It can also be used to handle specific error by throw error in the handler.
(any)
(any)
(any)
(any)
(any)
A decorator to mute errors when conditions are met.
(Error | object | undefined)
:
If the error is muted(not thrown to upper level) it is accessible in the return value.
(any)
(any)
(any)
(any)
(any)
A decorator to retry action until condition met or reach maxRetries.
(object | Array)
:
The data returned from the original action call.
(any)
(any)
(any)
(any)
(any)
A decorator used on actions when they are not chained with a logged upper-level call this decorator attaches action name to the error then being thrown to a logged level.
(any)
(any)
(any)
(any)
(any)
A decorator to attach standard log behaviour to action bypass: when logger instance is not available in context augment: parse action name and added to action meta to be chained in sub-actions after: log success event, with options to include param and result error: log error event, with option to parse error.
(any)
(any)
(any)
(any)
(any)
(any)
(any)
A decorator used to poll remote endpoint with action.
(Object
= {}
)
Config.
Name | Description |
---|---|
config.until Function?
|
The function to set conditions to stop the polling and return the data. |
config.mapping Function?
(default res=>res )
|
The mapping function to transform response to the data format needed. |
config.interval number?
(default 1000 )
|
Time to wait between each polling call. |
config.timeout number?
(default 30*1000 )
|
The max time to wait for the polling before abort it. |
Function
:
The decorated function returns the polling result.
A decorator to timing action execution time in both success/error cases and send metrics using the client attached in context.
An opinionated decorator creator to ensure predictable behaviour with light test.
(Object
= {}
)
Options.
Name | Description |
---|---|
options.bypassHook BypassHook?
(default ()=>false )
|
Define a condition to bypass the decorator. |
options.storeHook StoreHook?
(default ()=>{} )
|
Define a function to prepare values to be accessed by other hooks. |
options.beforeHook BeforeHook?
(default ()=>{} )
|
Define a function to be executed before calling action. |
options.actionHook ActionHook?
(default (param,meta,context,action)=>action(param,meta,context) )
|
Define a function to return an augumented action with updated args. |
options.afterHook AfterHook?
(default ()=>{} )
|
Define a function to be executed after the action call succeeds. |
options.errorHook ErrorHook?
(default ()=>{} )
|
Define a function to be executed if error is thrown from action call. |
Decorator
:
The decorator with behaviour defined by the hooks and returns the expected result of the action.
sleep for n ms before resolving the Promise
(Number)
duration in ms
Promise
:
a Promise for async/await control flow