core-apigateway-client

1.0.3 • Public • Published

API-GATEWAY CLIENT

Intro

This npm package is for interacting with the apigateway service. It is used to communicate with the core-api-gateway service.

Installation

$ npm install --save core-apigateway-client

Sample usage

Client initialization

const { ApiGatewayClient } = require('core-apigateway-client');

const client = new ApiGatewayClient({
  baseRoute: 'http://localhost:5900', // optional (default: dev server)
  services: {
    // required services to call i.e.- serviceKey: 'service-name-as-value'  
  },
  retryCount: 6,            // optional
  logger: true,             // optional (true, false, winston)
});

You can then send any request to the core-apigateway service

const service = 'security';
const action = 'authenticate';
const target = 'admin';
const payload = { email: 'me@example.com', password: '1234' }

try {
  const res = await client.send({
    service,
    action,
    target,
    payload,
  });
  // do something with res
} catch (error) {
  // do something with error
}

/core-apigateway-client/

    Package Sidebar

    Install

    npm i core-apigateway-client

    Weekly Downloads

    1

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    22.5 kB

    Total Files

    15

    Last publish

    Collaborators

    • jfabfab