Created
May 10, 2015 22:03
-
-
Save daffl/90fe92273a11df04b31f to your computer and use it in GitHub Desktop.
feathers-hooks examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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