featuris

Configuration

Configurations for Featuris are exposed through the environment variables. Set them using a .env file and a single environment variable, USE_DOTENV="true" or use one of Docker, Docker Compose or Kubernetes to inject these environment variables. See more below at Methods For Environment Variable Injection.

Environment Variables

TL;DR

ALLOWED_ORIGINS

Defaults to undefined

Is is strongly recommended to set the CORS headers for API calls. This flag allows you to set the hostnames from which the Access-Control-Allow-Origin headers should return "*" for. Separate individual hostnames with a comma (,).

When this environment variable is not set (ie undefined), all calls from all hosts will have the header Access-Control-Allow-Origin: * set.

Example

Assuming our development environment is located at http://localhost:3000 and our production deployment at https://www.mysite.com:

ALLOWED_ORIGINS="http://localhost:3000,https://www.mysite.com"

DEFAULT_DATA_SOURCE

Defaults to "data/features"

This defines the location where Featuris will look for feature manifests. This can be a relative path or an absolute path. By default, we use the data/features directory relative to the working directory of Featuris and run through all .yaml, .yml and .json files.

Example

Assuming a directory created at /etc/Featuris/manifests containing your feature manifests:

DEFAULT_DATA_SOURCE="/etc/Featuris/manifests"

LOGS_COLORIZE

Defaults to "false"

This defines where logs should be colorized. Useful in development.

LOGS_DISABLED

Defaults to "false"

This defines whether logs should be displayed.

LOGS_FORMAT

Defaults to "text"

This defines whether the logs should be in JSON (value: "json") or plain text (value: "text"). JSON is useful for streaming to a centralized logs collator such as Fluentd.

LOGS_SHOW_LEVEL

Defaults to "false"

This defines whether an additional level field is added to the logs. Levels look like debug/info/access/warn/error and they provide an easy way to filter logs if necessary.

LOGS_STRINGIFY

Defaults to "false"

This defines whether the logs should be stringified and is applicable only when LOGS_FORMAT is set to "json". For example, when this is set to "true", logs will look like this:

{"thisIsHardToRead":true,"becauseItsAll":"concatenated","without":"spaces"}

When set to "false", logs will look like this:

{
  "thisIsHardToRead": false,
  "becauseItsAll": "spaced out",
  "with": "pretty tabs"
}

NODE_ENV

Defaults to undefined

This sets the environment which Featuris should run in and also the environment for which keys from the feature manifest will be returned. See the section, Feature Manifest > Environment Key, for more information.

PORT

Defaults to 3000

This sets the port on which Featuris will listen to.

PIVOTAL_TRACKER_API_KEY

Defaults to undefined

This sets the Pivotal Tracker API Key for use with acceptance flags. See more on integrations at this page.

Methods For Environment Variable Injection

Via .env

Create a file named .env in the root of Featuris and pass the environment variable USE_DOTENV=true when running npm start.

Via Dockerfile

You can also build another Dockerfile with the ENV directive specifying the environment variables:

FROM zephinzer/Featuris:latest
ENV NODE_ENV=production \
    LOGS_DISABLED=true
...

Via docker run

docker run -e "NODE_ENV=production" -e "LOGS_DISABLED=true" -p 3000:3000 zephinzer/Featuris:latest

Via docker-compose.yaml

version: "3"
services:
  feature_toggle_server:
    image: zephinzer/Featuris:latest
    environment:
      - NODE_ENV=production
      - LOGS_DISABLED=true
    ...

Via k8s-manifest.yaml

kind: Deployment
apiVersion: apps/v1beta1
metadata:
  name: Featuris-feature-toggle-server
  labels:
    app: Featuris
    env: production
spec:
  replicas: 1
  template:
    spec:
      containers:
      - name: feature_toggle_server
        image: zephinzer/Featuris:latest
        ports:
        - containerPort: 3000
        env:
          - name: NODE_ENV
            value: production
          - name: PORT
            value: 3000
          - name: LOGS_DISABLED
            value: "true"