Skip to content

Instantly share code, notes, and snippets.

@Saad-ISAA
Last active May 14, 2022 10:50
Show Gist options
  • Save Saad-ISAA/feb6427f35cba58cb3b017a18cd32187 to your computer and use it in GitHub Desktop.
Save Saad-ISAA/feb6427f35cba58cb3b017a18cd32187 to your computer and use it in GitHub Desktop.
Strapi Bootsrap with Pub Sub config
'use strict';
const { psInit, psSubscribe, psPublish } = require('./helper/pubsub');
module.exports = {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
* This gives you an opportunity to extend code.
*/
// eslint-disable-next-line @typescript-eslint/no-empty-function
register(/*{ strapi }*/) { },
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
async bootstrap({ strapi }) {
strapi.pubsub = psInit();
// publish to topic for logging start of processes
psPublish(strapi.pubsub, process.env.TOPIC_INIT_STRAPI, { message: `Strapi init at ${Date.now().toLocaleString()}` });
psSubscribe(strapi.strapi, process.env.SUBS_INIT_STRAPI, (message) => {
console.log(message);
});
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment