Skip to main content

Context and Skip Default Behavior

Context

In each lifecycle function (before and after), we have access to a global object called context which holds common data between event

NameTypeDescription
resourceTypekeyOf typeOf EnumResourceTypethe type of the resource: MessageBroker ProjectConfiguration Service
resourceInfoAppInfothe general data of the app:name, description, version, id, URL, and settings (resource settings)
entitiesEntity[]the list of entities in the service
rolesrolesthe list of roles in the service
pluginInstallationspluginInstallationsa list of the installed plugins
topicsTopic[]a list of topics that are connected to a specific service
modulesModuleMapMap of the generated modules (files)
DTOsDTOslist of the generated DTOs
pluginsPluginMapa Map of the event name with its before and after function, and event params
loggerBuildLoggera logger that can be used to log messages inside the plugin. It will allow to create logs in the user facing build log
utilsContextUtilan interface that exposes utility functionalities and properties, such as skipDefaultBehavior - will be explained later, and importStaticModules - provides access to the static generated files
clientDirectoriesclientDirectorieshelps to determine where a specific file or folder will be generated in the generated admin-ui folder baseDirectory``srcDirectory``authDirectory``publicDirectory``apiDirectory
serverDirectoriesserverDirectorieshelps to determine where a specific file or folder will be generated in the generated server folder baseDirectory srcDirectory authDirectory scriptsDirectory messageBrokerDirectory

Skip Default Behavior

In the before function, you can call the skipDefaultBehavior from the context and set it to true (by default its value is false):

context.utils.skipDefaultBehavior = true;

As a result, the default functionality won’t be executed and you will have to provide your own logic. You can do it after the skip in the before function, or in the after function.

info

Using skipDefaultBehavior and not providing an alternative functionality can cause unexpected behavior. For example, if the skipped event generates files that are imported from other files, so use it wisely and carefully.