JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 76
  • Score
    100M100P100Q83299F
  • License MIT

Configuring a Node.js application based on Spring Cloud Config

Package Exports

  • node-scc-config

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-scc-config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Configure your Node.js applications using Spring Cloud Config

Build Status Download Status

Benefits

  • Server and client data decryption

Installation

npm install node-scc-config
yarn add node-scc-config

Usage

  1. Create a client-side pointer to the Spring Cloud Config service

    const client = new SpringCloudConfigClient('your spring cloud config endpoint address...');
  2. Configuring the client before calling

    client
        .beforeLoad(s => ({
            your request options...
        }))
  3. Configuring the client after the call

    Chipher marker defaults to '{cipher}'

  • Chipher marker
    client
        .afterLoad(d => d
            .setChipherMarker('your chipher marker...')
  • Data replacer by templates

    Example: { ['{HOST}']: 'test', ['{SERVICE_NAME}']: 'app-service' }

    client
        .afterLoad(d => d
            .setReplacer('your template...')
  • Data decryption
    • client
      client
          .afterLoad(d => d
              .setDecryptor(new AesDecryptor('your secret key or password...')))
    • server
      client
          .afterLoad(d => d
              .setDecryptor(new ServiceDecryptor('your decryption endpoint address...')))
  • Source preparation
    • Merge source

      Default implementation if no function is specified

      client
          .afterLoad(d => d
              .setMergeSource<AppServiceApiConfig>((configuration?: TConfiguration<AppServiceApiConfig>) => {
                  your code to merge source...
              }))
    • Prepare source

      Default implementation if no function is specified

      client
          .afterLoad(d => d
              .setPrepareSource<AppServiceApiConfig>((source: Record<string, any>) => {
                  your code to prepare source...
              }))
  1. Call loading the configuration

    await client.load();
  2. Using the loaded configuration

    type AppServiceApiConfig = {
        logLevel: string;
        options: {
            service: {
                url: string;
                login: string;
                password: string;
            };
        };
        testOptions: {
            url: string;
        };
    };
    
    const config = getConfiguration<AppServiceApiConfig>();