Socket
Socket
Sign inDemoInstall

trooba-http-api

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trooba-http-api

generic API for trooba http and ajax transports


Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

trooba-http-api

codecov Build Status NPM Downloads Known Vulnerabilities

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

Get Involved

Install

npm install trooba-http-api --save

Usage

Export via transport

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

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

module.exports = function transport(pipe, config) {
    pipe.on('request', function (request) {
        request = _.merge(request || {}, config);
        Wreck.request(request, function onResponse(err, response) {
            if (err) {
                pipe.throw(err);
                return;
            }
            pipe.respond(response);
        });
    });

    // inject api
    pipe.set('client:default', httpfy);
};

Attach to any pipe

var Trooba = require('trooba');

var client = new Trooba()
.use(function someHandler() {})
.use(function someHandler() {})
.use(function someHandler() {})
.use('trooba-http-api')
.build()
.create('client:default'); // since it injects default at ''client:default''

client.delete('path/to/resource').end(console.log);

Keywords

FAQs

Package last updated on 05 Oct 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc