jsender-plus

0.0.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i jsender-plus

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • samora