1.0.0-20230205123242 • Published 1 year ago

@timetoogo/ff-client v1.0.0-20230205123242

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

FF Proxy - Node Client

FF includes a client library for Node.js written in Typescript.

Installation

Install the latest prerelease version of @timetoogo/ff-client from NPM:

npm install --save @timetoogo/ff-client

See latest versions here

Usage

Using FfClient

The FfClient class provides the ability to send a HTTP request to an FF proxy:

const { FfClient } = require("@timetoogo/ff-client");

const client = new FfClient({
  ipAddress: "127.0.0.1",
  port: 8080,
  preSharedKey: 'mykey'
});

client.sendRequest({
  request: "GET / HTTP/1.1\nHost: www.google.com\n\n",
  https: true
});

Using FfClientAgent

If you have existing code that relies on the built-in http or https modules, the SDK provides a custom request agent to send requests to an FF proxy.

const http = require("http");
const { FfClientAgent } = require("@timetoogo/ff-client");

const agent = new FfClientAgent({
  ipAddress: "127.0.0.1",
  port: 8080,
  preSharedKey: 'mykey',
  mockResponse: 200
});

const request = http.request({
  method: "GET",
  path: "/",
  host: "www.google.com",
  agent
});

request.end();
0.1.0

4 years ago