# bullet-train-nodejs

> Bullet Train lets you manage features flags and remote config across web, mobile and server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.

Latest version **1.0.6** (published 2020-10-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install bullet-train-nodejs
pnpm add bullet-train-nodejs
yarn add bullet-train-nodejs
bun add bullet-train-nodejs
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-10-26 |
| First published | 2018-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 52.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | SSG |
| Maintainers | kyle-ssg, twstuart, dabeeeenster |
| Keywords | nodejs, bullet train, feature flagger, continuous deployment |

## Links

- npm: https://www.npmjs.com/package/bullet-train-nodejs
- Repository: https://github.com/SolidStateGroup/bullet-train-nodejs-client
- Homepage: http://bullet-train.io
- Issues: https://github.com/SolidStateGroup/bullet-train-nodejs-client/issues
- npm.io page: https://npm.io/package/bullet-train-nodejs

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.1.2

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-10-26
- 0.0.2 (beta) — 2018-06-05
- 1.0.5 — 2020-08-25
- 1.0.4 — 2020-08-25
- 1.0.3 — 2020-08-25
- 1.0.2 — 2020-07-21
- 1.0.1 — 2019-09-05
- 0.1.2 — 2018-06-11
- 0.1.1 — 2018-06-06
- 0.1.0 — 2018-06-05
- 0.0.9 — 2018-06-05
- 0.0.8 — 2018-06-05
- 0.0.7 — 2018-06-05
- 0.0.6 — 2018-06-05
- 0.0.5 — 2018-06-05
- … 3 more at https://npm.io/package/bullet-train-nodejs/versions

## README

<img width="100%" src="https://raw.githubusercontent.com/SolidStateGroup/bullet-train-frontend/master/hero.png"/>

# Bullet Train Client

[![Gitter](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/SolidStateGroup/bullettrain?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![npm version](https://badge.fury.io/js/bullet-train-nodejs.svg)](https://badge.fury.io/js/bullet-train-nodejs)
[![](https://data.jsdelivr.com/v1/package/npm/bullet-train-nodejs/badge)](https://www.jsdelivr.com/package/npm/bullet-train-nodejs)

The SDK clients for NodeJS [https://bullet-train.io/](https://www.bullet-train.io/). Bullet Train allows you to manage feature flags and remote config across multiple projects, environments and organisations.

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See running in production for notes on how to deploy the project on a live system.

## Installing

### VIA npm

```npm i bullet-train-nodejs --save```

## Usage

### Retrieving feature flags for your project

*For full documentation visit [https://docs.bullet-train.io](https://docs.bullet-train.io)*

```javascript
var bulletTrain = require("bullet-train-nodejs");

bulletTrain.init({
    environmentID:"<YOUR_ENVIRONMENT_KEY>"
});

bulletTrain.hasFeature("header", '<My User Id>')
.then((featureEnabled) => {
    if (featureEnabled) {
        //Show my awesome cool new feature to this one user
    }
});
bulletTrain.hasFeature("header")
.then((featureEnabled) => {
    if (featureEnabled) {
        //Show my awesome cool new feature to the world
    }
});

bulletTrain.getValue("header", '<My User Id>')
.then((value) => {
    //Show some unique value to this user
});

bulletTrain.getValue("header")
.then((value) => {
    //Show a value to the world
});
```

### Available Options

| Property        | Description           | Required  | Default Value  |
| ------------- |:-------------:| -----:| -----:|
| ```environmentID```     | Defines which project environment you wish to get flags for. *example ACME Project - Staging.* | **YES** | null
| ```onError```     | Callback function on failure to retrieve flags. ``` (error)=>{...} ``` |  **NO** | null
| ```defaultFlags```     | Defines the default flags if there are any | **NO** | null
| ```api```     | Use this property to define where you're getting feature flags from, e.g. if you're self hosting. |  **NO** | https://bullet-train-api.dokku1.solidstategroup.com/api/v1/

### Available Functions

| Property        | Description |
| ------------- |:-------------:|
| ```init```     | Initialise the sdk against a particular environment
| ```hasFeature(key)```     | Get the value of a particular feature e.g. ```bulletTrain.hasFeature("powerUserFeature") // true```
| ```hasFeature(key, userId)```     | Get the value of a particular feature for a user e.g. ```bulletTrain.hasFeature("powerUserFeature", 1234) // true```
| ```getValue(key)```     | Get the value of a particular feature e.g. ```bulletTrain.getValue("font_size") // 10```
| ```getValue(key, userId)```     | Get the value of a particular feature for a specificed userId e.g. ```bulletTrain.getValue("font_size", 1234) // 15```
| ```getFlags()```     | Trigger a manual fetch of the environment features, if a user is identified it will fetch their features
| ```getFlagsForUser(userId)```     | Trigger a manual fetch of the environment features with a given userId
| ```setTrait(userId, key, value)```     | Set the name/value pair for the specified userId
| ```getTrait(userId, key)```     | Retrieve the value for the specified userId and Trait key

### Identifying users

Identifying users allows you to target specific users from the [Bullet Train dashboard](https://www.bullet-train.io/).
You can include an optional user identifier as part of the `hasFeature` and `getValue` methods to retrieve unique user flags and variables.

## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/kyle-ssg/c36a03aebe492e45cbd3eefb21cb0486) for details on our code of conduct, and the process for submitting pull requests to us.

## Getting Help

If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search existing issues in order to prevent duplicates.

## Get in touch

If you have any questions about our projects you can email <a href="mailto:support@bullet-train.io">support@bullet-train.io</a>.

## Useful links

[Website](https://bullet-train.io)

[Documentation](https://docs.bullet-train.io/)

[Code Examples](https://github.com/BulletTrainHQ/bullet-train-docs)

[Youtube Tutorials](https://www.youtube.com/channel/UCki7GZrOdZZcsV9rAIRchCw)

---
_Source: https://npm.io/package/bullet-train-nodejs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
