Skip to content

fmiras/ff-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feature Flag Service

This API allows other services to know which customer is able or not to use a certain feature of a platform.

Installation

To setup the server clone the repository and run one of the following commands on the root project folder:

yarn # if using Yarn
npm install # if using NPM

Then create an .env file setting up the enviroment variables. Here's an example:

MONGO_URL=mongodb://localhost:27017/
MONGO_DB=ffservice
CACHE_TIME=86400000

Then just run

npm start

Server is going to listen at port 3000 by default. For development use npm run dev instead so the project watch the files and have some more debug logging.

Usage

The API has only a single endpoint at / and receives as a path variable an ID with an optional query with the requested features. Here are a few examples (with a Mongo database loaded with database-example.js file):

Retrieving customers:

Return all features set versions:

GET http://localhost:3000/2

Response:

{
    "mfa": "1.7.1",
    "logging": "1.0.0"
}

Return state of specific features (version number if set or false if latest version)

GET http://localhost:3000/1?query=logging,roles,mfa

Response:

{
  "logging": "2.1.0",
  "roles": "1.7.0",
  "mfa": false
}

Creating customers:

Create a customer:

POST http://localhost:3000

Request body:

{
  "features": {
    "roles": "1.0.0"
  }
}

Response:

{
    "customerId": 4,
    "features": {
        "roles": "1.0.0"
    }
}

Editing customers

Add or edit existing features to a customer:

PATCH http://localhost:3000/1

Request body:

{
  "features": {
    "roles": "1.0.1"
  }
}

Response:

{
    "customerId": 1,
    "features": {
        "logging": "2.1.0",
        "roles": "1.0.1",
        "sms": "3.0.0"
    }
}

Replace existing features of customer:

PUT http://localhost:3000/1

Request body:

{
  "features": {
    "roles": "1.0.1"
  }
}

Response:

{
    "customerId": 1,
    "features": {
        "roles": "1.0.1"
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published