# objectify-response

> details like code, status, message in an object

Latest version **1.0.8** (published 2020-09-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install objectify-response
pnpm add objectify-response
yarn add objectify-response
bun add objectify-response
```

## 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 | 1.0.8 |
| Published | 2020-09-09 |
| First published | 2020-02-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | aljohn villarubia |
| Maintainers | aljohnv |
| Keywords | objectify, response, status, code |

## Links

- npm: https://www.npmjs.com/package/objectify-response
- Repository: https://github.com/avillarubia/objectify-response
- Homepage: https://github.com/avillarubia/objectify-response#readme
- Issues: https://github.com/avillarubia/objectify-response/issues
- npm.io page: https://npm.io/package/objectify-response

## Dependencies (1)

- [http-status](https://npm.io/package/http-status.md) ^1.4.2

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2020-09-09
- 1.0.7 — 2020-02-27
- 1.0.6 — 2020-02-26
- 1.0.5 — 2020-02-26
- 1.0.4 — 2020-02-25
- 1.0.3 — 2020-02-25
- 1.0.2 — 2020-02-25
- 1.0.1 — 2020-02-25
- 1.0.0 — 2020-02-19

## README

# objectify-response

- Returns 200 from all server responses regardless the server returns with status code 400 and up.
- Helps you avoid sending 400 and up status codes to your client-side applications.
- Gives you cleaner responses displayed in browser console.

## Installation

```shell
npm install --save objectify-response
```

## Importing

```js
import objectifyResp from 'objectify-response'; // ES6
var objectifyResp = require('objectify-response'); // ES5 with npm
```

## Dependencies
```http-status```

## Usage
**Example**

```js
router.post('/', async (req, res) => {
    const token = generateToken()

    return objectifyResp(res, token)
})
```

```js
router.post('/', async (req, res) => {
    const { item } = getItem()

    if(!item)
        return objectifyResp(res, 'Item is not found.', 404)
})
```

```js
router.post('/', async (req, res) => {
    const object = {}

    if(!item)
        return objectifyResp(res, object, 404)
})
```

## Returns
Returns 200 from all server responses regardless the server returns 400 and up.

**Example return from the first usage example.**

HTTP/1.1 200 OK
```js
{ 
    code: 200
    name: 'OK' //auto generated name of the error based on the provided error code.
    message: 'Returns the generated token string'
}
```

**Example return from the second usage example.**

HTTP/1.1 200 OK
```js
{ 
    code: 404
    name: 'NOT_FOUND' //auto generated name of the error based on the provided error code.
    message: 'Item is not found.'
}
```

**Example return from the third usage example.**

HTTP/1.1 200 OK
```js
{ 
    code: 404
    name: 'NOT_FOUND' //auto generated name of the error based on the provided error code.
    message: {}
}
```

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