Interface ActionMiddleware

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 } } }

interface ActionMiddleware {
    global: boolean;
    name: string;
    postProcessor?: Function;
    preProcessor?: Function;
    priority?: number;


global: boolean

Is this middleware applied to all actions?

name: string

Unique name for the middleware.

postProcessor?: Function

Called after the action runs.

preProcessor?: Function

Called before the action runs. Has access to all params, before sanitization. Can modify the data object for use in actions.

priority?: number

Module load order. Defaults to api.config.general.defaultMiddlewarePriority.