1.1.0 • Published 7 years ago
koa-izanami-proxy v1.1.0
koa-izanami-proxy
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@alphayarn add koa-izanami-proxy@alphaUsage
A client configuration must contain a host, clientId and clientSecret:
hostis your Izanami server URLclientIdandclientSecretare 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())
izanamiProxy({ app, featureClientConfig })
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: '*')
}