2021-01-27 11:52:02 +01:00
|
|
|
'use strict';
|
|
|
|
|
2021-02-02 12:27:24 +01:00
|
|
|
// eslint-disable-next-line node/no-extraneous-require
|
|
|
|
const { features } = require('strapi/lib/utils/ee');
|
2021-01-27 11:52:02 +01:00
|
|
|
const routes = require('./routes');
|
|
|
|
|
|
|
|
module.exports = strapi => ({
|
|
|
|
beforeInitialize() {
|
2021-01-28 10:50:36 +01:00
|
|
|
strapi.config.middleware.load.before.unshift('features-routes');
|
2021-01-27 11:52:02 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
initialize() {
|
|
|
|
loadFeaturesRoutes();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const loadFeaturesRoutes = () => {
|
|
|
|
for (const [feature, getFeatureRoutes] of Object.entries(routes)) {
|
|
|
|
if (features.isEnabled(feature)) {
|
2021-02-02 12:27:24 +01:00
|
|
|
strapi.admin.config.routes.push(...getFeatureRoutes);
|
2021-01-27 11:52:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|