From d9f1f39ee42125dc73501de76e95eae90a79b059 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 12 Aug 2019 17:08:22 +0200 Subject: [PATCH] Add documentation --- .../configurations/configurations.md | 29 ++++++++++++++++++- .../files/config/functions/bootstrap.js | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/3.0.0-beta.x/configurations/configurations.md b/docs/3.0.0-beta.x/configurations/configurations.md index 3a614b05d4..2bf143c9cb 100644 --- a/docs/3.0.0-beta.x/configurations/configurations.md +++ b/docs/3.0.0-beta.x/configurations/configurations.md @@ -83,9 +83,36 @@ The `bootstrap` function is called at every server start. You can use it to add Here are some use cases: -- Create an admin user if there isn't. +- Create an admin user if there isn't one. - Fill the database with some necessary data. - Check that the database is up-and-running. +- Load some envrionments variables. + +The bootstrap function can be synchronous or asynchronous + +**Synchronous** + +```js +module.exports = () => { + // some sync code +}; +``` + +**Return a promise** + +```js +module.exports = () => { + return new Promise(/* some code */); +}; +``` + +**Be async** + +```js +module.exports = async () => { + await someSetup(); +}; +``` ### CRON tasks diff --git a/packages/strapi-generate-new/lib/resources/files/config/functions/bootstrap.js b/packages/strapi-generate-new/lib/resources/files/config/functions/bootstrap.js index 917d16f39b..a33be48b92 100644 --- a/packages/strapi-generate-new/lib/resources/files/config/functions/bootstrap.js +++ b/packages/strapi-generate-new/lib/resources/files/config/functions/bootstrap.js @@ -6,6 +6,8 @@ * * This gives you an opportunity to set up your data model, * run jobs, or perform some special logic. + * + * See more details here: https://strapi.io/documentation/3.0.0-beta.x/configurations/configurations.html#bootstrap */ module.exports = () => {};