Socket
Socket
Sign inDemoInstall

@allgemein/http

Package Overview
Dependencies
91
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @allgemein/http

Library for http request backend abstraction.


Version published
Maintainers
1
Install size
1.54 MB
Created

Readme

Source

@allgemein/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 @allgemein/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()

Keywords

FAQs

Last updated on 06 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc