1.0.0 • Published 9 years ago
express-json-response v1.0.0
express-response
middleware for express http response
Installation
$ npm install express-json-response
Quick Start
var express = require('express'),
expressResponse = require('express-json-response'),
app;
app = express();
app.use(expressResponse());
app.get('/', function(req, res) {
res.sendData({message: 'example'});
});
// Available methods
// 2xx Success
res.sendOk()
res.sendCreated()
res.sendData()
// 4xx Client Error
res.sendBadRequest()
res.sendUnauthorized()
res.sendForbidden()
res.sendNotFound()
res.sendMethodNotAllowed()
res.sendConflict()
// 5xx Server Error
res.sendServerError()
Tests
To run the test suite, first install the dependencies, then run npm test
:
$ npm install
$ npm test
License
1.0.0
9 years ago