# api-meady-easy

> Node.js http-utility functions commonly used in API development.

Latest version **2.0.0** (published 2018-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install api-meady-easy
pnpm add api-meady-easy
yarn add api-meady-easy
bun add api-meady-easy
```

## 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.0.0 |
| Published | 2018-10-01 |
| First published | 2018-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Roger Mori |
| Maintainers | rogermori |
| Keywords | http, utils, request, utils, response, utils |

## Links

- npm: https://www.npmjs.com/package/api-meady-easy
- Repository: https://github.com/rogermori/api-meady-easy
- Homepage: https://github.com/rogermori/api-meady-easy#readme
- Issues: https://github.com/rogermori/api-meady-easy/issues
- npm.io page: https://npm.io/package/api-meady-easy

## Dependencies (1)

- [objects-made-easy](https://npm.io/package/objects-made-easy.md) ^1.0.1

## 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.0.0 (latest) — 2018-10-01
- 1.0.4 — 2018-10-01
- 1.0.3 — 2018-10-01
- 1.0.2 — 2018-10-01
- 1.0.1 — 2018-09-29
- 1.0.0 — 2018-09-28

## README

# Api Utilities
Node.js http-utility functions commonly used in  API development.
## Supported Language Features
This project uses JavaScript [ES6](https://github.com/lukehoban/es6features)

#### Install
```
> npm install --save api-made-easy 
```
#### Run tests
```
> npm run test 
```
#### Run example
```
> node request/body/example
```
### Usage

#### Body intersection
Creates a new object from a given object by inclusion.
````
const Body = require('api-made-easy');
const difference = require('./actions').difference;

const bodyRequest = {
  name: 'Peter Parker',
  grades: ['a', 'c'],
  age: null,
  dob: undefined,
  roles: [],
};

const bodyIntersection = Body(intersection(bodyRequest));
const nameNGrades = bodyIntersection(['name', 'grades']);
const ageNdob = bodyIntersection(['age', 'dob']);
const address = bodyIntersection(['address']);
console.log(nameNGrades); // { name: 'Peter Parker', grades: [ 'a', 'c' ] }
console.log(ageNdob); // { age: null, dob: undefined }
console.log(address); // { address: undefined }
```` 
### Body Difference
Creates a new object from a given object by exclusion.
````
const Body = require('api-made-easy').Body;
const difference = require('api-made-easy').difference;

const bodyDifference = Body(difference(bodyRequest));
const bodyWithNoRoles = bodyDifference(['roles']);
console.log(bodyWithNoRoles);
/*
{   name: 'Peter Parker',
    grades: [ 'a', 'c' ],
    age: null,
    dob: undefined
}
*/
````  
### StandardResponse
StandardResponse wraps all http-responses into successful 200-http-responses. 
So, the caller-client decides the next step. Also, StandardResponse could return the original request. 

Upon receiving 400's or 500's http-response-codes, some frameworks will re send the request automatically again and again 
. With the StandardResponse the caller-client can modify this behaviour.    

````
const StandardResponse = require('api-made-easy').StandardResponse;

const happyResponse = new StandardResponse(
    true,
    'All good',
    {id: 1},
    {id:1, name: 'Peter Parker'}
).getResponse();
````

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