mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-02 06:33:42 +08:00
27 lines
715 B
TypeScript
27 lines
715 B
TypeScript
import { Configuration } from '@midwayjs/decorator';
|
|
import * as DefaultConfig from './config/config.default';
|
|
import { IMidwayContainer } from '@midwayjs/core';
|
|
import { CoolRpc } from './rpc';
|
|
import { CoolRpcDecorator } from './decorator';
|
|
|
|
@Configuration({
|
|
namespace: 'cool:rpc',
|
|
importConfigs: [
|
|
{
|
|
default: DefaultConfig,
|
|
},
|
|
],
|
|
})
|
|
export class CoolRpcConfiguration {
|
|
async onReady(container: IMidwayContainer) {
|
|
global['moleculer.transactions'] = {};
|
|
(await container.getAsync(CoolRpc)).init();
|
|
// 装饰器
|
|
await container.getAsync(CoolRpcDecorator);
|
|
}
|
|
|
|
async onStop(container: IMidwayContainer): Promise<void> {
|
|
(await container.getAsync(CoolRpc)).stop();
|
|
}
|
|
}
|