Registering middleware

Middleware is registered on the server with backend.use():

backend.use(action, function(context, next) {
  // Do something with the context

  // Call next when ready. Can optionally pass an error to stop
  // the current action, and return the error to the client
  next(error)
})

Valid actions and their corresponding context shape can be found here.