Skip to content

Instantly share code, notes, and snippets.

@daffl
Created May 10, 2015 22:03
Show Gist options
  • Select an option

  • Save daffl/90fe92273a11df04b31f to your computer and use it in GitHub Desktop.

Select an option

Save daffl/90fe92273a11df04b31f to your computer and use it in GitHub Desktop.
feathers-hooks examples
// Add a delay to test slower connections
function addDelay(delay) {
return function(hook, next) {
setTimeout(next, delay);
}
}
function timestamp(name) {
return function(hook, next) {
hook.data[name] = new Date();
next();
}
}
app.service('users')
// Add a one second delay
.before(addDelay(1000))
// Add updated_at and created_at
.before({
create: timestamp('created_at'),
update: timestamp('updated_at'),
patch: timestamp('updated_at')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment