Is there a best practice for a callback after a blueprint route in SailsJS 11.x?
I have an API where Users
can submit Idea
s. After the Idea
is created, if it's the User
's first Idea
they should get a Badge
. As far as I can tell there are two places to put this functionality.
- Copy/Override the Sails rest blueprint, add the functionality to the
Idea.create()
callback function. - Add a lifecycle callback for the
afterCreate
action on theIdea
model.
I'm assuming any functionality I write in terms of granting badges should be put in a Service so it can be shared among the different models. It seems like option 1 wouldn't be as tightly coupled, but would lead to fatter controllers.