Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 3, 2025
1 parent 625bbd5 commit 5579a42
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/loader/egg_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ export class EggLoader {
this.configMeta = {};

const target: EggAppConfig = {
appMiddleware: [],
middleware: [],
coreMiddleware: [],
};

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface CustomLoaderConfigItem {

export interface EggAppConfig extends Record<string, any> {
coreMiddleware: string[];
appMiddleware: string[];
middleware: string[];
customLoader?: Record<string, CustomLoaderConfigItem>;
controller?: {
supportParams?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion test/loader/mixin/load_custom_loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5579a42

Please sign in to comment.