Skip to content

Commit

Permalink
fix: component env filter (#1234)
Browse files Browse the repository at this point in the history
* fix: component env filter

* fix: jest version
  • Loading branch information
czy88840616 committed Aug 18, 2021
1 parent c826e68 commit bfb44b7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "a web framework for complex Node.js application",
"version": "1.0.0",
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/jest": "^27.0.0",
"@types/node": "^15.0.1",
"@vercel/ncc": "^0.29.0",
"dotenv": "^10.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/egg-layer/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ describe('/test/index.test.ts', () => {

it('should test param with get', done => {
request(app)
.get('/echo/%E6%B5%8B%E8%AF%95')
.get('/echo/' + encodeURI('测试'))
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect('测试')
.expect('%E6%B5%8B%E8%AF%95')
.expect(200, done);
});
});
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/baseFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,13 @@ export abstract class BaseFramework<
} else {
// 普通类写法
const providerId = getProviderId(cycle.target);
cycle.instance =
await this.getApplicationContext().getAsync<ILifeCycle>(providerId);
if (this.getApplicationContext().registry.hasDefinition(providerId)) {
cycle.instance =
await this.getApplicationContext().getAsync<ILifeCycle>(providerId);
}
}

lifecycleInstanceList.push(cycle);
cycle.instance && lifecycleInstanceList.push(cycle);
}

// exec onConfigLoad()
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ILogger, LoggerOptions } from '@midwayjs/logger';
* 生命周期定义
*/
export interface ILifeCycle {
onConfigLoad?(container: IMidwayContainer, app?: IMidwayApplication): Promise<void>;
onReady(container: IMidwayContainer, app?: IMidwayApplication): Promise<void>;
onStop?(container: IMidwayContainer, app?: IMidwayApplication): Promise<void>;
}
Expand Down

0 comments on commit bfb44b7

Please sign in to comment.