Is this middleware applied to all actions?
Unique name for the middleware.
Optional
postCalled after the action runs.
Optional
preCalled before the action runs. Has access to all params, before sanitization. Can modify the data object for use in actions.
Optional
priorityModule load order. Defaults to api.config.general.defaultMiddlewarePriority
.
var middleware = { name: 'userId checker', global: false, priority: 1000, preProcessor: async (data) => { if(!data.params.userId){ throw new Error('All actions require a userId') } }, postProcessor: async (data) => { if(data.thing.stuff == false){ data.toRender = false } } }