-
Notifications
You must be signed in to change notification settings - Fork 73
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
Feature Request: Support forFeatureAsync to handle Hooks with injectables #394
Comments
Question: isn't the facility in Typegoose for using hooks not enough? Scott |
@smolinari is the question directed to me? if yes, then no, hooks alone aren’t enough. This feature request allows for using Dependency Injection configurations in the hooks which isn’t possible atm. |
Ah, Gotcha. I would have put that password hashing logic in a service anyway. But, I guess that's just me. 😁 Scott |
@smolinari Right. I used to do the same but then the logic gets repetitive (while I also tried to DRY it). There are some different use-cases like post-processing some field changed. Eg: a wysiwyg editor sending raw markdown to the backend, the backend post-processes the markdown and saves html in the db. Whenever this field gets updated, run the post-processing again. Stuffs like this make a lot of sense in a format of hooks and being able to inject services when constructing hooks would be a lot nicer, and the logic is encapsulated. |
@nartc Hello, how did you solve it? |
@87789771 - You do the hashing in either the User or Auth services, where it actually belongs. Scott |
Same as
nestjs/mongoose
https://docs.nestjs.com/techniques/mongodb#hooks-middlewareThis will allow for something like the following:
The text was updated successfully, but these errors were encountered: