Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

kingkong

2.0.2 • Public • Published

King Kong Build Status

HTTP Client For Kong Api Gateway

King is a small library for managing api, consumer and plugin configuration of a KONG cluster. The primary purpose is to keep API configuration in sync by either creating or updating records using the kong admin api.

It is not intended to configure kong servers

Version 2.x targest Kong v0.10.0+, for Kong v0.9.0, use Version 1.x of this project

A kingkong instance can take multiple hosts and will round-robbin between them. Currently it will not remove hosts that fail to respond.

require('util');
var King = require('kingkong');
 
var k = new King({
    hosts:'http://localhost:8001http://localhost:8002'
    ,sync:true // auto sync configuration
    ,apis:[{
          "upstream_url": "http://127.0.0.1:3000/api/v1",
          "request_path": "/fakeservice",
          "strip_request_path": true,
          "name": "integration",
          "plugins":{
            "http-log":{
              config:{
                  http_endpoint:'http://127.0.0.1:3005',
                  method:'POST'
              } 
            }
          }
    }]
    ,onSync: function(){
        console.log('synced');
    }
});

List all APIs

You can fetch all apis currently registered using the list method

var King = require('kingkong')
 
var k = new King({
    hosts:['http://localhost:8001', 'http://localhost:8002']
});
 
k.list('apis').then( console.log)

List all Plugins

You can fetch all Plugins currently registered using the list method

var King = require('kingkong')
 
var k = new King({
    hosts:['http://localhost:8001', 'http://localhost:8002']
});
 
k.list('plugins').then( console.log )

List all Consumers

You can fetch all Consumers currently registered using the list method

var King = require('kingkong')
 
var k = new King({
    hosts:['http://localhost:8001', 'http://localhost:8002']
});
 
k.list('consumers').then( console.log )

Install

npm i kingkong

DownloadsWeekly Downloads

55

Version

2.0.2

License

MIT

Last publish

Collaborators

  • avatar
  • avatar