1.1.0 • Published 3 years ago

http2-kable v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Kable

This is a simple HTTP/2 client that uses promises. It wraps the low-level Node.js HTTP/2 client and thus only works with Node. It is not intended to be a full featured HTTP client like Axios but, until Axios supports HTTP/2 on Node, this makes using HTTP/2 in Node apps a little easier.

This is intended to work with Node 14 and up.

Install

Add the package to your project:

yarn add http2-kable

or

npm install http2-kable

Usage

Import the Kable class into your Javascript or Typescript project where needed:

const { Kable } = require('http2-kable');

or

import { Kable } from 'http2-kable');

Because this client is intended for long-lasting connections you then connect and hold on to the connection, reusing it for any requests to the same base URL, before closing it.

const kable = await Kable.connect({ baseUrl: 'https://some.host' });

const responseFromGet = await kable.get('/path/to/resource');

const buffer = // fill buffer with data to post (e.g. encoded from Protobuf)
const responseFromPost = await kable.post('/another/resource', buffer, {
  'content-length': buffer.byteLength,
});

// once finished with the connection:
await kable.close();
1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago