pretty-response

Express middleware that exposes functions to work with HTTP status codes

Usage no npm install needed!

<script type="module">
  import prettyResponse from 'https://cdn.skypack.dev/pretty-response';
</script>

README

Pretty Response

Build Status Coverage Status Code Climate npm version

Express middleware that exposes functions to work with HTTP status codes

Pretty Response exposes all HTTP codes as functions on response as a middleware. So you can plug it wherever you want to and have a more expressive code than using standard response.status(CODE).

Install

$ npm install --save-dev pretty-response

Usage

var express = require('express')
var pretty = require('pretty-response')

var app = express()
    .use(pretty)

Or you can use specifically on the routes you want to.

Then you can use descriptive names as functions to create RFC 2616 specific response:

app
.get('/', function (req, res, next) {
    res.ok().send()
})

All functions are using camel-cased names. For instance notFound, internalServerError and created. It's easier if you take a look at the the codes file.

License

MIT