开发环境
由于 ApolloY
在开发环境中使用的是 betayun
环境的服务,连接 betayun 服务需要添加 hosts
和 连接VPN
HOST: HOST 配置 (opens new window)
VPN: VPN 指南 (opens new window)
import { Controller, Get } from '@tiger/common'
import { ApolloValue } from '@tiger/base-provider'
@Controller()
export class ExampleController {
@ApolloValue('app_id', 'key')
apollo_key: number;
@Get()
index() {
console.log(this.apollo_key)
return 'hello'
}
}
装饰器 @ApolloValue(appId: string, key: string, option: { cluster?: string, namespace?: string })
参数:
appId
: ApolloY
的应用名称key
: ApolloY
namespace 下的 keyoption.cluster
: ApolloY
应用的集群, 默认 default
option.namespace
: ApolloY
应用的namespace, 默认 application
借助框架的依赖注入能力,默认值直接赋值给属性即可:
import { Controller, Get } from '@tiger/common'
import { ApolloValue } from '@tiger/base-provider'
@Controller()
export class ExampleController {
@ApolloValue('app_id', 'key')
apollo_key: number = 'default_value';
@Get()
index() {
console.log(this.apollo_key)
return 'hello'
}
}