mirror of
https://github.com/strapi/strapi.git
synced 2025-10-17 02:53:22 +00:00
Merge pull request #3436 from strapi/fix/403-documentaton
Fix beforeInitialize middlewares can modify order or middlewares
This commit is contained in:
commit
0ceb50ac6b
@ -65,6 +65,20 @@ module.exports = async function() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Run init functions
|
||||
*/
|
||||
|
||||
// Run beforeInitialize of every middleware
|
||||
await Promise.all(
|
||||
enabledMiddlewares.map(key => {
|
||||
const { beforeInitialize } = this.middleware[key].load;
|
||||
if (typeof beforeInitialize === 'function') {
|
||||
return beforeInitialize();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// run the initialization of an array of middlewares sequentially
|
||||
const initMiddlewaresSeq = async middlewareArr => {
|
||||
for (let key of uniq(middlewareArr)) {
|
||||
@ -91,20 +105,6 @@ module.exports = async function() {
|
||||
middlewaresAfter
|
||||
);
|
||||
|
||||
/**
|
||||
* Run init functions
|
||||
*/
|
||||
|
||||
// Run beforeInitialize of every middleware
|
||||
await Promise.all(
|
||||
enabledMiddlewares.map(key => {
|
||||
const { beforeInitialize } = this.middleware[key].load;
|
||||
if (typeof beforeInitialize === 'function') {
|
||||
return beforeInitialize();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// before
|
||||
await initMiddlewaresSeq(middlewaresBefore);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user