Giter VIP home page Giter VIP logo

koa-izanami-proxy's Introduction

koa-izanami-proxy

Build Status Coverage Status

Izanami proxy for Koa

Why?

In order to use Izanami features on the client side you have to use a proxy. To call Izanami APIs you need to provide authentication keys and you don’t want the keys to be exposed on the client side. For further details, please see the documentation.

The proxy provided by izanami-node has been written for express, thus it does not work with Koa.

Install

npm install koa-izanami-proxy@alpha
yarn add koa-izanami-proxy@alpha

Usage

You must specify at least one client configuration option depending on your needs (either featureClientConfig, experimentClientConfig or configClientConfig).
One must contain a host, clientId and clientSecret:

  • host is your Izanami server URL
  • clientId and clientSecret are secrets you've created in Izanami keys management.

Other options are available for proxy configuration.

const Koa = require('koa')
const cors = require('@koa/cors')
const izanamiProxy = require('koa-izanami-proxy')

const featureClientConfig =  {
  host: 'http://localhost:8080', // Izanami server URL
  clientId: process.env.CLIENT_ID || 'client',
  clientSecret: process.env.CLIENT_SECRET || 'client1234',
}

const app = new Koa()

app.use(cors())

const proxyConfiguration = { app, featureClientConfig }

izanamiProxy(proxyConfiguration)

app.listen(5000, () => {
  console.log('Example app listening on port 5000!')
})

Proxy configuration

{
  path: '/your/path', // default: '/api/izanami'
  featureClientConfig, // Optional
  configClientConfig, // Optional
  experimentClientConfig, // Optional
  experimentWonPath: '/your/won/path', // default: '/api/experiments/won'
  experimentDisplayedPath: '/your/displayed/path',  // default: '/api/experiments/displayed'
  app, // Koa app 
  pattern: 'my.namespace.*' // The pattern to filter experiments, configs and features (default: '*')
}

koa-izanami-proxy's People

Contributors

charlyx avatar

Stargazers

GAURAV avatar  avatar Francois Desmier avatar Chris Woodrow avatar

Watchers

 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.