express-json-response

1.0.0 • Public • Published

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

MIT

Package Sidebar

Install

npm i express-json-response

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jakjothi