0.0.2 • Published 2 years ago

@yunflyjs/yunfly-plugin-apollo v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@yunflyjs/yunfly-plugin-apollo

yunfly apollo plugin.

Usage

  1. install
yarn add @yunflyjs/yunfly-plugin-apollo
  1. declare plugins in config/config.plugin.ts
/**
 * yunfly plugin
 */
const plugins: {[key:string]: string}[] = [
  {
    name: 'apollo',
    package: '@yunflyjs/yunfly-plugin-apollo',
    lifeHook: 'beforeStart'
  }
];
// 
export default plugins;
  1. enable plugins in config/config.default.ts
config.apollo = {
  enable: true,
  // serviceName: 'example-apollo-service',
  // serviceUrl: 'http://xxx.com',
  // secret: 'xxxxxx',
  // namespace: 'application'
}

config options

interface

export interface ApolloConfig {
  enable?: boolean;
  secret?: string;
  serviceUrl?: string;
  namespace?: string;
  serviceName?: string;
}

description

fieldtyperequireddefaultnotes
enablebooleanyesfalseenable the plugin
secretstringnoprocess.env.APOLLO_ACCESSKEY_SECRETapollo secret
serviceUrlstringnoprocess.env.APOLLO_META_SERVER_URLapollo host url
namespacestringnoapplicationapollo config namespace
serviceNamestringnopackageJson.name

api

  • getApolloConfig

api usage

import { getApolloConfig } from '@yunflyjs/yunfly-plugin-apollo';

console.log('getApolloConfig',getApolloConfig);
  • get apollo config in controller
import { Controller, Get } from '@yunflyjs/yunfly';
import { getApolloConfig } from '@yunflyjs/yunfly-plugin-apollo';
 
@Controller()
export class ExampleController {
  @Get('/users')
  getApolloConfig() {
    return getApolloConfig();
  }
}

env

process.env.APOLLO_META_SERVER_URL

apollo url host address, need to start with http:// or https://.

  • priority

config.apollo.serviceUrl > process.env.APOLLO_META_SERVER_URL

process.env.APOLLO_ACCESSKEY_SECRET

if the apollo management side has enabled the secret key, this parameter needs to be passed.

  • priority

config.apollo.secret > process.env.APOLLO_ACCESSKEY_SECRET

其他说明

  1. apollo hot update
  2. failed to retry 5 times
0.0.2

2 years ago

0.0.1

2 years ago