1.0.7 • Published 4 years ago

@benbakhar/resty v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Resty

A tiny, zero dependencies Express middleware for clear and concise http response handling.

npm i -S resty

Usage

const app = require('express')();
const resty = require('resty');

app.use(resty());

app.get('/ping', (req, res) => res.success());

which will respond with the following response:

{
    "message": "success",
    "payload": {}
}

Methods

response.success(payload, message)
response.created(payload, message)
response.badRequest(payload, message)
response.unauthorized(payload, message)
response.forbidden(payload, message)
response.notFound(payload, message)
response.error(message)

Options

PropertyTypeDescriptionExample
statusCodesObjectset custom status code for specific http response{redirect: 307}
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.0-beta

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.0

5 years ago