Last active
May 14, 2022 10:50
-
-
Save Saad-ISAA/feb6427f35cba58cb3b017a18cd32187 to your computer and use it in GitHub Desktop.
Strapi Bootsrap with Pub Sub config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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