-
Notifications
You must be signed in to change notification settings - Fork 286
feature(hooks): add decorators for declaring hooks #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #101 +/- ##
=========================================
+ Coverage 95.66% 96.3% +0.64%
=========================================
Files 66 99 +33
Lines 761 893 +132
Branches 107 114 +7
=========================================
+ Hits 728 860 +132
Misses 11 11
Partials 22 22
Continue to review full report at Codecov.
|
Thank you! |
Thank you for implementing this. It's a great feature! |
I've made a beta release, in which this feature is included now :)
|
@RobinBuschmann can I use an async function like this? @BeforeUpdate
@BeforeCreate
static async hashPassword(instance: User) {
// this will be called when an instance is created or updated
instance.password = await bcrypt.hash(instance.password, 10);
} |
@mengkheang Yes. A hook function may return a |
@natesilva thank for the explaining :) |
|
Thank you! |
I had to re-do the pull request after I botched the original branch. The only change is that this centralizes the hook implementation logic into the hooks services file.
Fixes #88, replaces #97.