Events
The IMA.js server exposes emitter and Event objects that can be used to handle events and adjust the server behavior.
You can listen to any of the events below by calling emitter.on(eventName, event => {}). See the @esmj/emitter documentation for more details.
Note: All IMA server events have built-in Performance Tracking support. You can access the performance tracker via
event.context.perfto measure and monitor your server operations.
Special Events
CreateBootConfig
Emitted within Event.Request after event.context.bootConfig is initialized. You can modify the boot config here.
Example:
emitter.on(Event.CreateBootConfig, ({ req, context }) => {
const { bootConfig } = context;
bootConfig.settings.$App = {
...bootConfig.settings.$App,
isWebPSupported: req?.headers?.accept?.includes('image/webp'),
};
});