# ApolloY

# 准备工作

开发环境

由于 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 下的 key
  • option.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'
  }
}