jsender-plus
v0.0.2
Published
A few more Express response helper methods for JSender.
Downloads
4
Readme
JSender +
A few more Express helper methods for JSender.
Methods add specific HTTP Status Codes.
Installation
npm install --save jsender-plus
Usage
var express = require('express')
, jsender = require('jsender')
, jsenderPlus = require('jsender-plus')
var app = express()
app.use(jsender())
app.use(jsenderPlus())
app.post('/users', function (req, res) {
// some logic here
// ...
// fails validation
if (errors)
return res.failValidation(errors)
// on success
res.successCreated(data)
})
API
res.successCreated(data)
- data: Optional object to send in JSON response.
HTTP Status: 201
res.failValidation(data)
- data: Required object of validation errors to send in JSON response.
HTTP Status: 400
res.errorNotFound(item, data, code)
- item: Optional string stating item that cannot be found.
- data: Optional object
- code: Optional number
HTTP Status: 404
License
MIT