Options
All
  • Public
  • Public/Protected
  • All
Menu

This is the API reference for the LaunchDarkly Server-Side SDK for Node.js.

In typical usage, you will call init once at startup time to obtain an instance of LDClient, which provides access to all of the SDK's functionality.

For more information, see the SDK reference guide.

Index

Type aliases

A LaunchDarkly context object.

LDFlagValue: any

The types of values a feature flag can have.

Flags can have any JSON-serializable value.

LDLogLevel: "debug" | "info" | "warn" | "error" | "none"

Logging levels that can be used with basicLogger.

Set BasicLoggerOptions.level to one of these values to control what levels of log messages are enabled. Going from lowest importance (and most verbose) to most importance, the levels are 'debug', 'info', 'warn', and 'error'. You can also specify 'none' instead to disable all logging.

Functions

  • Creates an object that allows you to use local files as a source of feature flag state, instead of connecting to LaunchDarkly. This would typically be used in a test environment.

    deprecated

    Import this function from the launchdarkly-node-server-sdk/integrations module instead. It will be removed from the main SDK module in a future release.

    Parameters

    Returns object

  • Provides a simple LDLogger implementation.

    This logging implementation uses a simple format that includes only the log level and the message text. Output is written to the standard error stream (console.error). You can filter by log level as described in BasicLoggerOptions.level.

    To use the logger created by this function, put it into LDOptions.logger. If you do not set LDOptions.logger to anything, the SDK uses a default logger that is equivalent to ld.basicLogger({ level: 'info' }).

    example

    This example shows how to use basicLogger in your SDK options to enable console logging only at warn and error levels.

      const ldOptions = {
    logger: ld.basicLogger({ level: 'warn' }),
    };
    example

    This example shows how to use basicLogger in your SDK options to cause log output to go to console.log instead of console.error.

      const ldOptions = {
    logger: ld.basicLogger({ destination: console.log }),
    };

    Parameters

    • Optional options: BasicLoggerOptions

      Configuration for the logger. If no options are specified, the logger uses { level: 'info' }.

    Returns LDLogger

  • Creates an instance of the LaunchDarkly client.

    Applications should instantiate a single instance for the lifetime of the application. The client will begin attempting to connect to LaunchDarkly as soon as it is created. To determine when it is ready to use, call LDClient.waitForInitialization, or register an event listener for the "ready" event using LDClient.on.

    Important: Do not try to instantiate LDClient with its constructor (new LDClient()); the SDK does not currently support this.

    Parameters

    • key: string

      The SDK key.

    • Optional options: LDOptions

      Optional configuration settings.

    Returns LDClient

    The new client instance.

Generated using TypeDoc