Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Commit

Permalink
feat: support mw
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Apr 30, 2020
1 parent 300b6cd commit 788e417
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/faas/src/config.default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const middleware = [];
export const keys = '';
19 changes: 19 additions & 0 deletions packages/faas/src/configuration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Configuration, App, Config } from '@midwayjs/decorator';
import { ILifeCycle, IMidwayContainer } from '@midwayjs/core';

@Configuration({
importConfigs: ['./config.default'],
})
export class FaaSContainerConfiguration implements ILifeCycle {
@App()
app;

@Config('middleware')
middleware;

async onReady(container: IMidwayContainer) {
for (const mw of this.middleware) {
this.app.use(mw);
}
}
}
2 changes: 2 additions & 0 deletions packages/faas/src/starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ export class FaaSStarter implements IFaaSStarter {
} as MidwayFaaSInfo);
}
}

this.initConfiguration('./configuration', __dirname);
// add configuration support
this.prepareConfiguration();

Expand Down

0 comments on commit 788e417

Please sign in to comment.