Hooks

In /bin/server.js you will find some pre-operation hooks. These will run after auth but before the operation.

We've used callbacks to add parameters on get and getOne to our queries to limit what certain users see in the results. We've also use the post, put and delete to fire emits on an external Websocket server.

config.pre_hooks = {
    get: (req, res, next) => {
        next();
    },
    getOne: (req, res, next) => {
        next();
    },
    post: (req, res, next) => {
        next();
    },
    put: (req, res, next) => {
        next();
    },
    delete: (req, res, next) => {
        next();
    },
};

To suppress a callback, pass _silence=true as a parameter. This helps avoid infinite loops, for instance when your PUT updates the same model.