Git Product home page Git Product logo

launchdarkly-node's Introduction

launchdarkly-node

LaunchDarkly server-side SDK wrapper for Node intended to provide a modern API and enforce best practices.

Use

Init connection to LaunchDarkly when launching your app with

const { init } = require('@wisersolutions/launchdarkly-node')

async function startApp() {
  await init('YOUR_LAUNCH_DARKLY_APP_KEY', options)
  // … launch the rest of your app
}

Then request a feature variation anywhere in your app with

const { variation } = require('@wisersolutions/launchdarkly-node')

async function handleSomeRequest(context) {
  const user = getUserFrom(context)
  const isFeature1Enabled = await variation('some-boolean-flag-key', user)
  const feature2Variation = await variation('some-multi-variant-flag-key', user, 'default-variant')
  
  if (!isFeature1Enabled) return /* … */

  switch (feature2Variation) {
    case 'variant-one': return /* … */
    case 'variant-two': return /* … */
    case 'default-variant':
    default: return /* … */
  }
}

See SDK docs for argument details.

Development

Install

Install dependencies using:

npm install

Develop

After you modify sources, run the following (or set up your IDE to do it for you):

  • format the code using npm run format
  • lint it using npm run lint
  • test it using npm test

and fix the errors, if there are any.

Publish

Publishing is done in two steps:

  1. Create a new version tag and push it to the repository:
    npm version <patch|minor|major>
    git push --follow-tags
  2. Build and publish the new version as a npm package:
    npm publish --access public

launchdarkly-node's People

Contributors

hon2a avatar

Watchers

 avatar  avatar  avatar  avatar

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.