1.0.7 • Published 5 years ago

commons-http v1.0.7

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

node-commons-http

Build Status codecov Dependency Status

This is a abstract implementation for a generic http requests api, which can be backed by different implementations. Like got, request, node-fetch or others.

The default implementation is uses got package.

Install

npm i commons-http got

Usage

import {HttpFactory, IHttpResponse, IHttp, IHttpStream} from "commons-http";

let httpFactory = await HttpFactory.load();
let http:IHttp = httpFactory.create();

// use as promise
let resp:IHttpResponse<any> = await http.get('http://example.com');
console.log(resp.body)

// use as stream
let stream:IHttpStream<any> = http.get('http://example.com',{stream:true});
stream.pipe(fs.createWriteStream('test.file'));

await stream.asPromise()
1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago