# trooba-http-api

> generic API for trooba http and ajax transports

Latest version **2.1.1** (published 2020-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install trooba-http-api
pnpm add trooba-http-api
yarn add trooba-http-api
bun add trooba-http-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2020-04-10 |
| First published | 2016-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dmytro Semenov |
| Maintainers | dimichgh, kprakasam |
| Keywords | ajax, http, api |

## Links

- npm: https://www.npmjs.com/package/trooba-http-api
- Repository: https://github.com/dimichgh/trooba-http-api
- Homepage: https://github.com/dimichgh/trooba-http-api#readme
- Issues: https://github.com/dimichgh/trooba-http-api/issues
- npm.io page: https://npm.io/package/trooba-http-api

## Dependencies (1)

- [lodash.template](https://npm.io/package/lodash.template.md) ^4.5.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2020-04-10
- 2.1.0 — 2019-10-23
- 2.0.3 — 2017-10-10
- 2.0.2 — 2017-10-05
- 2.0.1 — 2017-05-24
- 2.0.0 — 2016-12-12
- 1.0.1 — 2016-12-02
- 1.0.0 — 2016-11-30

## README

# trooba-http-api

[![codecov](https://codecov.io/gh/trooba/trooba-http-api/branch/master/graph/badge.svg)](https://codecov.io/gh/trooba/trooba-http-api)
[![Build Status](https://travis-ci.org/trooba/trooba-http-api.svg?branch=master)](https://travis-ci.org/trooba/trooba-http-api) [![NPM](https://img.shields.io/npm/v/trooba-http-api.svg)](https://www.npmjs.com/package/trooba-http-api)
[![Downloads](https://img.shields.io/npm/dm/trooba-http-api.svg)](http://npm-stat.com/charts.html?package=trooba-http-api)
[![Known Vulnerabilities](https://snyk.io/test/github/trooba/trooba-http-api/badge.svg)](https://snyk.io/test/github/trooba/trooba-http-api)

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

## Get Involved

- **Contributing**: Pull requests are welcome!
    - Read [`CONTRIBUTING.md`](.github/CONTRIBUTING.md) and check out our [bite-sized](https://github.com/trooba/trooba-http-api/issues?q=is%3Aissue+is%3Aopen+label%3Adifficulty%3Abite-sized) and [help-wanted](https://github.com/trooba/trooba-http-api/issues?q=is%3Aissue+is%3Aopen+label%3Astatus%3Ahelp-wanted) issues
    - Submit github issues for any feature enhancements, bugs or documentation problems
- **Support**: Join our [gitter chat](https://gitter.im/trooba) to ask questions to get support from the maintainers and other Trooba developers
    - Questions/comments can also be posted as [github issues](https://github.com/trooba/trooba-http-api/issues)

## Install

```
npm install trooba-http-api --save
```

## Usage

### Export via transport
```js
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

```js
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);
```

---
_Source: https://npm.io/package/trooba-http-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
