Giter Site home page Giter Site logo

node-client's Introduction

Doppler Node.js Library

contributions welcome Version Downloads Codacy Badge Try on RunKit

The Doppler Node library provides convenient access to the Doppler API from applications written for only server-side JavaScript.

Installation

Install the package with:

npm install doppler-client --save

Usage

The package needs to be configured with your account's api key which is available in your Doppler account, pipeline identifier and the environment name:

Environment Variables Required

Please add these environment variables to your .env file in the root directory or on your infra provider.

DOPPLER_API_KEY = <API Key>
DOPPLER_PIPELINE = <Pipeline ID>
DOPPLER_ENVIRONMENT = <Environment Name>

Lookup Priority

Doppler will look for these variables in 3 places with the following priority:

  1. Passed in as initialization arguments
  2. Read from environment variables
  3. Read from .env file

Install with Environment Variables

This installation method will expect the DOPPLER_API_KEY, DOPPLER_PIPELINE, DOPPLER_ENVIRONMENT as environment variables.

require("doppler-client")()


// Rest of Your Application
const example_variable = process.env.EXAMPLE_VARIABLE

Install with ENV File

This installation method will expect the DOPPLER_API_KEY, DOPPLER_PIPELINE, DOPPLER_ENVIRONMENT in a .env file.

require("doppler-client")({
  env_filepath: ".env"   // Defaults to ".env"
})


// Rest of Your Application
const example_variable = process.env.EXAMPLE_VARIABLE

Install with Arguments

This installation method will expect the api_key, pipeline, environment as arguments.

require("doppler-client")({
  api_key: process.env.DOPPLER_API_KEY,
  pipeline: process.env.DOPPLER_PIPELINE,
  environment: process.env.DOPPLER_ENVIRONMENT
})


// Rest of Your Application
const example_variable = process.env.EXAMPLE_VARIABLE

Key Best Practices

So if Doppler stores my environment variables, where should I keep my Doppler API keys?

That is a great question! We recommend storing your DOPPLER_API_KEY, DOPPLER_PIPELINE, and DOPPLER_ENVIRONMENT in a .env file or with your infra provider. That means the only variables you should be storing in your local environment are the Doppler keys. All other variables should be be fetched by the Doppler client.

Disable Overriding Environment Variables

If you would like to disable overriding environment variables, use this follow field.

const doppler = require("doppler-client")({
  override: false
})


// Rest of Your Application
const example_variable = doppler.get("EXAMPLE_VARIABLE")

Ignoring Specific Variables

In the case you would want to ignore specific variables from Doppler, say a port set by Heroku, you can add it the ignore_variables field.

require("doppler-client")({
  ignore_variables: ["PORT"]
})

Fallback to Backup

The Doppler client accepts a backup_filepath on init. If provided the client will write the Doppler variables to a backup file. If the Doppler client fails to connect to our API endpoint (very unlikely), the client will fallback to the keys provided in the backup file.

require("doppler-client")({
  backup_filepath: "./backup.env"
})

Extra Information

node-client's People

Contributors

bvallelunga avatar

Forkers

ryan-blunden

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.