/*
register for a callback before an action
op: 'create' | 'read' | 'update' | 'delete' | '*'
type: '<explicit type>' | '*'
listener signature is: function(intent, done)
listener function must call done() to continue, or done(err) to abort the action
note: if more than one listener is registered for an action, listeners will be called asynchronously and the first
error (if any) will be binding, so there is no guarantee any particular listener will be called
}
function before(op, type, listener) {
  if (!_.isFunction(listener)) { throw new Error('Callback must be a function'); }
  if (!registeredListeners[op][type]) { registeredListeners[op][type] = []; }
  registeredListeners[op][type].push(listener);
}