strapi-plugin-website-builder
Version:
A plugin for Strapi Headless CMS that provides the ability to trigger website builds manually, periodically or through model events.
21 lines (17 loc) • 682 B
JavaScript
;
const { getService } = require('../utils/common');
const { bootstrapCron } = require('./bootstrapCron');
const { bootstrapEvents } = require('./bootstrapEvents');
module.exports = async ({ strapi }) => {
const builds = getService({ strapi, name: 'settings' }).get({ path: 'builds' });
builds
.filter((b) => b.enabled || typeof b.enabled === 'undefined')
.forEach((build) => {
if (build.trigger.type === 'cron') {
bootstrapCron({ strapi, build });
} else if (build.trigger.type === 'event') {
bootstrapEvents({ strapi, build });
}
strapi.log.info(`[website builder] ${build.trigger.type} trigger enabled for ${build.name} build`);
});
};