Skip to content

betastreet/cluster-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version Build Status

cluster-request

A proxy module to send requests within a Kubernetes cluster of microservices

Installation

npm i --save cluster-request

Default Request Options

method: 'GET',
json: true,
gzip: true

Usage

const ClusterRequest = require('./lib');
const log = console;

const cluster = new ClusterRequest({
    log,
    defaultPort: 80,
    defaultReqOptions: {
        headers: {},
        json: true,
        gzip: false,
    },
});

cluster
    .request('echo.jsontest.com', '/a/b/c/d/e/1/data/some_data', {})
    .then((response) => {
        console.log('Status Code: ', response.statusCode);
        console.log('Body: ', response.body);

        cluster
            .validateResponse(response)
            .then((data) => {
                console.log('Response data: ', data);
            })
            .catch((err) => {
                console.log('Error: ', err);
            });
    })
    .catch((err) => {
        console.log('Error: ', err);
    });

Source: demo.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •