npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vodyani/apollo-client

v1.5.0

Published

🛸 apollo client sdk

Downloads

26

Readme

Vodyani apollo-client

🛸 携程 apollo 配置中心客户端。支持查询配置、订阅配置、使用开放中心提供的公共 API。

Npm Npm Npm License codecov Workflow semantic-release: angular

Installation

npm install @vodyani/apollo-client

Usage

Base Usage

Advanced Usage

ApolloHttpClient

import { ApolloHttpClient } from '@vodyani/apollo-client'

const options = {
  appId: 'your_apollo_app_id',
  configServerUrl: 'your_apollo_config_server_url',
  clusterName: 'your_apollo_cluster_name',
  currentIp: 'your_server_ip',
  secret: 'your_apollo_app_secret',
};

const httpClient = new ApolloHttpClient(options);

options

  • appId (require: ✅) apollo app id
  • configServerUrl (require: ✅) apollo config server url
  • clusterName (require: ❎) apollo app cluster name
  • currentIp (require: ❎) your server ip
  • secret (require: ❎) apollo app secret

ApolloHttpClient getConfig

const result = await httpClient.getConfig(
  'your_apollo_namespace',
  'properties'
)

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)

return

{
  'your_apollo_namespace_key': 'your_apollo_namespace_value'
}
  • Other than txt, which returns text, all formats are deserialized as objects.

ApolloHttpClient getConfigByCache

Call this method to access cached data.

const result = await httpClient.getConfigByCache(
  'your_apollo_namespace',
  'properties',
)

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)

return

{
  'your_apollo_namespace_key': 'your_apollo_namespace_value'
}
  • Other than txt, which returns text, all formats are deserialized as objects.

ApolloHttpClient getConfigNotifications

Call this method to initiate a long poll that listens to the specified namespace and receives updates back from the server.

const result = await httpClient.getConfigNotifications([
  {
    namespace: 'your_apollo_namespace',
    type: 'properties',
  }
])

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)

return

[
  {
    namespaceName: 'your_apollo_namespace_name';
    notificationId: 'your_apollo_notify_id',
  },
]

ApolloThirdPartyHttpClient

import { ApolloThirdPartyHttpClient } from '@vodyani/apollo-client'

const options = {
  appId: 'your_apollo_app_id',
  clusterName: 'your_apollo_cluster_name',
  env: 'your_apollo_env',
  secret: 'your_apollo_app_secret',
  token: 'your_apollo_open_api_token',
  portalServerUrl: 'your_apollo_portal_server_url',
  operator: 'your_apollo_open_api_operator_user_name',
};

const thirdPartyOptions = new ApolloThirdPartyHttpClient(options);

options

  • appId (require: ✅) apollo app id
  • env (require: ✅) apollo env
  • token (require: ✅) apollo app open api token
  • portalServerUrl (require: ✅) apollo portal server url
  • operator (require: ✅) apollo open api operator user name
  • clusterName (require: ❎) apollo app cluster name

ApolloThirdPartyHttpClient getConfig

const result = await thirdPartyOptions.getConfig(
  'your_apollo_namespace',
  'properties',
  'your_apollo_namespace_property'
)

const result = await thirdPartyOptions.getConfig(
  'your_apollo_namespace',
  'json'
)

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)
  • key string apollo app namespace property, this parameter is mandatory only when type properties is queried

return

{
  'your_apollo_namespace_key': 'your_apollo_namespace_value'
}

ApolloThirdPartyHttpClient saveConfig

If you need to publish the configuration, don't forget to call it after execution publishConfig

const result = await thirdPartyOptions.saveConfig(
  'your_apollo_namespace',
  'properties',
  'your_apollo_namespace_property'
)

const result = await thirdPartyOptions.saveConfig(
  'your_apollo_namespace',
  'json'
)

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)
  • key string apollo app namespace property, this parameter is mandatory only when type properties is queried

return

void

ApolloThirdPartyHttpClient deleteConfig

If you need to publish the configuration, don't forget to call it after execution publishConfig

const result = await thirdPartyOptions.deleteConfig(
  'your_apollo_namespace',
  'properties',
  'your_apollo_namespace_property'
)

const result = await thirdPartyOptions.deleteConfig(
  'your_apollo_namespace',
  'json'
)

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)
  • key string apollo app namespace property, this parameter is mandatory only when type properties is queried

return

void

ApolloThirdPartyHttpClient publishConfig

const result = await thirdPartyOptions.publishConfig(
  'your_apollo_namespace',
  'properties'
)

const result = await thirdPartyOptions.publishConfig(
  'your_apollo_namespace',
  'json'
)

params

  • namespace string apollo app namespace. (require: ✅)
  • type NamespaceType apollo app namespace type. (require: ✅)

return

void

Supported Configuration types

  • properties ✅
  • yaml ✅
  • yml ✅
  • json ✅
  • txt ✅
  • xml ❎

Questions

Team

|ChoGathK| |:-:| |ChoGathK|

Alt

License

Vodyani apollo-client is MIT licensed.