pretty-response
v1.0.1
Published
Express middleware that exposes functions to work with HTTP status codes
Downloads
6
Maintainers
Readme
Pretty Response
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