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

node-spring-cloud-config-client

v0.1.0-beta4

Published

Node-spring-cloud-config-client is a typescript implementation of spring cloud config client for node js.

Downloads

71

Readme

node-spring-cloud-config-client

Node-spring-cloud-config-client is a typescript implementation of spring cloud config client for node js.

Build

Install

# with npm
npm install node-spring-cloud-config-client

# or with Yarn
yarn add node-spring-cloud-config-client

Usage

In your application, use init method to start the load of variables in your process.env

//typescript
import {PropertySourcesContext} from 'node-spring-cloud-config-client'

//javascript
const {PropertySourcesContext} = require('node-spring-cloud-config-client')

...
...
// When in your server want to retry configuration from spring cloud config server
const propertySourcesContext = PropertySourcesContext.getInstance()
propertySourcesContext.load()
.subscribe(result => ...);

// You can also await execution of load method
const propertySourcesContext = PropertySourcesContext.getInstance()
const result = await propertySourcesContext.load()
.toPromise()

...

After load method, you can access data from env with process.env:

const database_password = process.env['db.password']

Options

client configuration

Properties dictionary:

| Property name | Default value | | ---- | ---- | | NSCCC_BASE_URI | http://localhost:8888 | | NSCCC_APPLICATION_NAME | application | | NSCCC_PROFILE | | | NSCCC_LABEL | |

With the above properties, node-spring-cloud-config-client can perform the rest call to the correct spring cloud config server.

Based on properties will be create the rest call:

<NSCCC_BASE_URI>/<NSCCC_APPLICATION_NAME>/<NSCCC_PROFILE>/<NSCCC_LABEL>

Example:

| NSCCC_BASE_URI | NSCCC_APPLICATION_NAME | NSCCC_PROFILE | NSCCC_LABEL | Rest call | | --------- | --------- | --------- | --------- | --------- | | | | | | http://localhost:8888/application/default | | http://your.server/ | | | | http://your.server/application/default | | | your-application-name | | | http://localhost:8888/your-application-name/default | | | | dev | | http://localhost:8888/application/dev | | | | | label | http://localhost:8888/application/default/label | | http://your.server/ | your-application-name | prod | | http://your.server/your-application-name/prod | | http://your.server/ | your-application-name | prod | label | http://your.server/your-application-name/prod/label |

fail strategy configuration

Properties dictionary:

| Property name | Default value | | ---- | ---- | | NSCCC_FAIL_FAST | false | | NSCCC_MAX_RETRY_ATTEMPTS | 6 | | NSCCC_SCALING_DURATION | 1000 |

You can specify what happen when call to propertie server fails.

If you want that when the call fails there are no error, set NSCCC_FAIL_FAST=false.

Otherwise, specify NSCCC_FAIL_FAST=true.

When NSCCC_FAIL_FAST not set 'true' or 'false', is like set NSCCC_FAIL_FAST to 'false'.

If NSCCC_FAIL_FAST set to true, is applied a retry that follow the properties NSCCC_MAX_RETRY_ATTEMPTS and NSCCC_SCALING_DURATION

With NSCCC_MAX_RETRY_ATTEMPTS specify how much times the retry will be performed.

With NSCCC_SCALING_DURATION specify what is scaling duration beetwen two retry.

Example:

export NSCCC_MAX_RETRY_ATTEMPTS=4
export NSCCC_SCALING_DURATION=500

Suppose that your config server is down and does not respond.

After the first call to config server, node-spring-cloud-config-client perform another call after 500 ms, after 1000 ms, after 1500 ms and after 2000 ms. After that node-spring-cloud-config-client emit error.

log configuration

Properties dictionary

| Property name | Default value | accepted value | if not accepted value | | ---- | ---- | ----- | ---- | | NSCCC_LOGGER_ENABLED | false | true/false | set to 'false' | | NSCCC_LOGGER_LEVEL | error | debug/info/error | set to 'error' |

You may turn on/off the log with property NSCCC_LOGGER_ENABLED.

You can specify level log with property NSCCC_LOGGER_LEVEL.