Notes
This section provides a set of useful notes and tips for using the Sodacore framework effectively.
Lifecycle: onInit
ALL Sodacore controlled module has an onInit
lifecycle method is called before any services are started, this means that regardless if it is a lookup, provider, controller, service, etc, the onInit
method will be called once during the application startup process, this is useful for setting up any initial state or configuration that your class may need before it is used.
@Autoload(x: number)
The @Autoload
decorator can take a number as an argument, where 1 is the highest priority, and 109 is the lowest priority, considering most routing is done in order, including HTTP routes, if you have a route that is very generic, e.g. /path/:id
, then you may want to set a lower priority on that controller so that more specific routes are matched first, all controllers default to priority 50 if not specified.