Question - content types hooks/filters
grzegorzbialy opened this issue · comments
Hi,
We're looking into integrating Burdy into our agency flow. So far it seems very promising but I check docs and code and cannot find any way to programatically modify content type (eg. page content) before or after create/save. I am thinking about some hooks (lifecycle in Strapi) or filter like page/preSave. For example I have some fields which should be autofilled based on other fields.
Also, I would like to run some additional code after publish - is there a filter for this?
Can you point me into the right direction or share your ideas for these scenarios?
Thanks!
Keep up the good work. :)
Hi @grzegorzbialy.
Thank you for using Burdy! This is something that we indeed plan to add to the project and it's in our current roadmap. The great thing about the hook integration is their flexibility and also, they can be added anywhere in the code. It's not currently a high priority in our list, but in one of the next iterations, we plan to add wrappers for each API call to include hooks in relevant places.
For example, if you take a look at the post controller .post('/posts'), we will add a hook that will allow you to completely override the behavior:
const post = await Hooks.applyFilter('posts/preSave', postObj, req); // post.controller.ts:228
This will allow you to completely change the postObj depending on some of your parameters. As an example req object currently contains the user, meaning that you would be able to add additional data (or mutations), perform some other saves, trigger actions, etc.