diff --git a/src/loader/egg_loader.ts b/src/loader/egg_loader.ts index 16edcca5..4d2b5c83 100644 --- a/src/loader/egg_loader.ts +++ b/src/loader/egg_loader.ts @@ -823,7 +823,7 @@ export class EggLoader { this.configMeta = {}; const target: EggAppConfig = { - appMiddleware: [], + middleware: [], coreMiddleware: [], }; @@ -855,8 +855,8 @@ export class EggLoader { extend(true, target, envConfig); // You can manipulate the order of app.config.coreMiddleware and app.config.appMiddleware in app.js - target.coreMiddlewares = target.coreMiddleware; - target.appMiddlewares = target.middleware; + target.coreMiddleware = target.coreMiddlewares = target.coreMiddleware || []; + target.appMiddleware = target.appMiddlewares = target.middleware || []; this.config = target; debug('[loadConfig] all config: %o', this.config); diff --git a/src/types.ts b/src/types.ts index d56ae9ae..e9cccc83 100644 --- a/src/types.ts +++ b/src/types.ts @@ -48,7 +48,7 @@ export interface CustomLoaderConfigItem { export interface EggAppConfig extends Record { coreMiddleware: string[]; - appMiddleware: string[]; + middleware: string[]; customLoader?: Record; controller?: { supportParams?: boolean; diff --git a/test/index.test.ts b/test/index.test.ts index 475f9482..1f62f630 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -37,9 +37,9 @@ describe('test/index.test.ts', () => { it('should expose types', () => { const config = { coreMiddleware: [], - appMiddleware: [], + middleware: [], } as EggAppConfig; - assert(config.appMiddleware); + assert(config.middleware); assert(config.coreMiddleware); }); }); diff --git a/test/loader/mixin/load_custom_loader.test.ts b/test/loader/mixin/load_custom_loader.test.ts index 7df1fdc2..c80d8ffd 100644 --- a/test/loader/mixin/load_custom_loader.test.ts +++ b/test/loader/mixin/load_custom_loader.test.ts @@ -103,7 +103,7 @@ describe('test/loader/mixin/load_custom_loader.test.ts', () => { try { app.loader.config = { coreMiddleware: [], - appMiddleware: [], + middleware: [], customLoader: { config: { directory: 'app/config',