Create a file that exports an event plugin object, for example src/events/my-custom/my-custom.ts:
exportconstmyEvents={onAfterAdd:async(document:any,user:any,trx:any,req:any,parentDocument:any,json:any,)=>{// Your custom logic hereconsole.log(`Document ${document.path} was created by ${user.id}`);},onAfterDelete:async(document:any,user:any,trx:any)=>{// Your custom logic hereconsole.log(`Document ${document.path} was deleted`);},};
Registering the plugin
In a profile file (e.g. src/profiles/core/index.ts), import and register your event plugin:
importeventsfrom'../../events';import{myEvents}from'../../events/my-custom/my-custom';// In your init() function:events.register(myCustom);