# Functions
The ./src/index.js
file includes global register, bootstrap and destroy functions that can be used to add dynamic and logic-based configurations.
# Register
The register
found in ./src/index.js
lifecycle function is an asynchronous function that runs before the application is initialized.
It can be used to:
- extend plugins
- extend content-types programmatically
- load some environment variables.
# Bootstrap
The bootstrap
lifecycle function found in ./src/index.js
is called at every server start.
It can be used to:
- create an admin user if there isn't one
- fill the database with some necessary data
- declare custom conditions for the Role-Based Access Control (RBAC) feature
The bootstrap function can be synchronous, asynchronous, or return a promise:
Synchronous function
module.exports = () => { // some sync code };
Copied to clipboard!
Asynchronous function
module.exports = async () => { await someSetup(); };
Copied to clipboard!
Function returning a promise
module.exports = () => { return new Promise(/* some code */); };
Copied to clipboard!
# Destroy
The destroy
function found in ./src/index.js
is an asynchronous function that runs before the application gets shut down.
It can be used to gracefully:
- stop services that are running
- clean up plugin actions (e.g. close connections, remove listeners, etc.).
← API tokens Cron jobs →