8000 GitHub - benbakhar/resty: A tiny, zero dependencies Express middleware for clear and concise http response handling.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

benbakhar/resty

Repository files navigation

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

Property Type Description Example
statusCodes Object set custom status code for specific http response {redirect: 307}

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0