Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chf007/nestjs-ctrip-apollo-client
Ctrip Apollo Client for Nestjs
https://github.com/chf007/nestjs-ctrip-apollo-client
apollo configuration-management ctrip-apollo-client nestjs
Last synced: 3 months ago
JSON representation
Ctrip Apollo Client for Nestjs
- Host: GitHub
- URL: https://github.com/chf007/nestjs-ctrip-apollo-client
- Owner: chf007
- License: mit
- Created: 2020-01-07T02:45:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-28T06:05:47.000Z (11 months ago)
- Last Synced: 2024-10-03T19:07:05.089Z (4 months ago)
- Topics: apollo, configuration-management, ctrip-apollo-client, nestjs
- Language: TypeScript
- Homepage: https://github.com/chf007/nestjs-ctrip-apollo-client
- Size: 519 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS CtripApolloClientModule
携程 [Apollo 配置中心](https://github.com/ctripcorp/apollo) NestJS 客户端,基于 [node-apollo-client](https://github.com/shinux/node-apollo-client) 封装。
## 安装
```bash
npm install nestjs-ctrip-apollo-client
```## 使用
```
// 导入 Module
import { Module } from '@nestjs/common';
import { CtripApolloClientModule } from 'nestjs-ctrip-apollo-client';@Module({
imports: [
CtripApolloClientModule.register({
configServerUrl: 'http://xxx.xxx.xxx.xxx',
appId: 'my-app',
cluster: 'default',
namespaces: ['application'],
initialConfigs: {},
listenOnNotification: true,
fetchCacheInterval: 5 * 60e3,
cachedConfigFilePath: '/tmp',
}),
],
providers: [],
})
export class AppModule {}// 使用 Service
import { Controller, Get } from '@nestjs/common';
import { CtripApolloClientService } from 'nestjs-ctrip-apollo-client';@Controller('api')
export class SomeController {
constructor(private readonly ctripApolloClientService: CtripApolloClientService) {}@Get('test')
async test() {
return await this.ctripApolloClientService.fetchConfig({
key: 'someConfigKey'
});
}
}```