Socket
Socket
Sign inDemoInstall

trooba-http-api

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    trooba-http-api

generic API for trooba http and ajax transports


Version published
Maintainers
1
Install size
906 kB
Created

Readme

Source

trooba-http-api

Provides a generic transport API to http/ajax/xhr trooba transports.

Install

npm install trooba-http-api --save

Usage

var Wreck = require('wreck');
var _ = require('lodash');

var httpfy = require('trooba-http-api');

module.exports = function httpTransportFactory(config) {

    var transport = function transport(requestContext, responseContext) {
        requestContext.options = _.merge(requestContext.options || {}, config);
        Wreck.request(requestContext.options, function onResponse(err, response) {
            responseContext.error = err;
            if (response) {
                responseContext.statusCode = response.statusCode;
                responseContext.response = response;
            }
            responseContext.next();
        });
    };

    transport = httpfy(transport);

    return transport;
};

Keywords

FAQs

Last updated on 02 Dec 2016

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