# 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

Path — ./src/index.js.

The register lifecycle function is an asynchronous function that runs before the application is initialized. It can be used to:

# Bootstrap

Path — ./src/index.js

The bootstrap lifecycle function 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.

The bootstrap function can be synchronous or asynchronous.

Synchronous

module.exports = () => {
  // some sync code
};

Return a promise

module.exports = () => {
  return new Promise(/* some code */);
};

Asynchronous

module.exports = async () => {
  await someSetup();
};

# Destroy

The destroy function is an asynchronous function that runs before the application gets shut down.

It can be used to gracefully: