node-friendly-response
How can I use it?...
It's very simple
Install it running...
npm install --save node-friendly-response
Require it as a node module...
var express = ;var Response = ; var app = ; app;
Using it with Bluebird
var express = ;var Bluebird = ;var Response = ; var app = ; app;
Express response errors handle
var express = ;var Bluebird = ;var Response = ; var ResponseError = ResponseResponseError; var app = ; app;
Available Status Codes
rescontinue // send a response with status 100resswitchingProtocols // send a response with status 101resprocessing // send a response with status 102 resok // send a response with status 200rescreated // send a response with status 201resaccepted // send a response with status 202resnonAuthoritativeInformation // send a response with status 203resnoContent // send a response with status 204resresetContent // send a response with status 205respartialContent // send a response with status 206resmultiStatus // send a response with status 207 resmultipleChoices // send a response with status 300resmovedPermanently // send a response with status 301resmovedTemporarily // send a response with status 302resseeOther // send a response with status 303resnotModified // send a response with status 304resuseProxy // send a response with status 305restemporaryRedirect // send a response with status 307 resbadRequest // send a response with status 400resunauthorized // send a response with status 401respaymentRequired // send a response with status 402resforbidden // send a response with status 403resnotFound // send a response with status 404resmethodNotAllowed // send a response with status 405resnotAcceptable // send a response with status 406resproxyAuthenticationRequired // send a response with status 407resrequestTimeout // send a response with status 408resconflict // send a response with status 409resgone // send a response with status 410reslengthRequired // send a response with status 411respreconditionFailed // send a response with status 412resrequestTooLong // send a response with status 413resrequestUriTooLong // send a response with status 414resunsupportedMediaType // send a response with status 415resrequestedRangeNotSatisfiable // send a response with status 416resexpectationFailed // send a response with status 417resinsufficientSpaceOnResource // send a response with status 419resmethodFailure // send a response with status 420resunprocessableEntity // send a response with status 422reslocked // send a response with status 423resfailedDependency // send a response with status 424 resinternalServerError // send a response with status 500resnotImplemented // send a response with status 501resbadGateway // send a response with status 502resserviceUnavailable // send a response with status 503resgatewayTimeout // send a response with status 504reshttpVersionNotSupported // send a response with status 505resinsufficientStorage // send a response with status 507
Available Errors
ResponseError = ResponseError.InternalServerError
ResponseError.BadRequest
ResponseError.Unauthorized
ResponseError.PaymentRequired
ResponseError.Forbidden
ResponseError.NotFound
ResponseError.MethodNotAllowed
ResponseError.NotAcceptable
ResponseError.ProxyAuthenticationRequired
ResponseError.RequestTimeout
ResponseError.Conflict
ResponseError.Gone
ResponseError.LengthRequired
ResponseError.PreconditionFailed
ResponseError.RequestTooLong
ResponseError.RequestUriTooLong
ResponseError.UnsupportedMediaType
ResponseError.RequestedRangeNotSatisfiable
ResponseError.ExpectationFailed
ResponseError.InsufficientSpaceOnResource
ResponseError.MethodFailure
ResponseError.UnprocessableEntity
ResponseError.Locked
ResponseError.FailedDependency
ResponseError.InternalServerError
ResponseError.NotImplemented
ResponseError.BadGateway
ResponseError.ServiceUnavailable
ResponseError.GatewayTimeout
ResponseError.HttpVersionNotSupported
ResponseError.InsufficientStorage
It works with request module too
var request = ;var Response = ;
This module provides...
res // For status codes 1xx;res // For status codes 2xx;res // For status codes 3xx;res // For status codes 4xx;res // For status codes 5xx;res // For status codes 4xx and 5xx;
and also...
res // if status code is 100res // if status code is 101res // if status code is 102 res // if status code is 200res // if status code is 201res // if status code is 202res // if status code is 203res // if status code is 204res // if status code is 205res // if status code is 206res // if status code is 207 res // if status code is 300res // if status code is 301res // if status code is 302res // if status code is 303res // if status code is 304res // if status code is 305res // if status code is 307 res // if status code is 400res // if status code is 401res // if status code is 402res // if status code is 403res // if status code is 404res // if status code is 405res // if status code is 406res // if status code is 407res // if status code is 408res // if status code is 409res // if status code is 410res // if status code is 411res // if status code is 412res // if status code is 413res // if status code is 414res // if status code is 415res // if status code is 416res // if status code is 417res // if status code is 419res // if status code is 420res // if status code is 422res // if status code is 423res // if status code is 424 res // if status code is 500res // if status code is 501res // if status code is 502res // if status code is 503res // if status code is 504res // if status code is 505res // if status code is 507
and also... listeners for events...
var ServerResponse = ServerResponse; ServerResponse // if status code is 100ServerResponse // if status code is 101ServerResponse // if status code is 102 ServerResponse // if status code is 200ServerResponse // if status code is 201ServerResponse // if status code is 202ServerResponse // if status code is 203ServerResponse // if status code is 204ServerResponse // if status code is 205ServerResponse // if status code is 206ServerResponse // if status code is 207 ServerResponse // if status code is 300ServerResponse // if status code is 301ServerResponse // if status code is 302ServerResponse // if status code is 303ServerResponse // if status code is 304ServerResponse // if status code is 305ServerResponse // if status code is 307 ServerResponse // if status code is 400ServerResponse // if status code is 401ServerResponse // if status code is 402ServerResponse // if status code is 403ServerResponse // if status code is 404ServerResponse // if status code is 405ServerResponse // if status code is 406ServerResponse // if status code is 407ServerResponse // if status code is 408ServerResponse // if status code is 409ServerResponse // if status code is 410ServerResponse // if status code is 411ServerResponse // if status code is 412ServerResponse // if status code is 413ServerResponse // if status code is 414ServerResponse // if status code is 415ServerResponse // if status code is 416ServerResponse // if status code is 417ServerResponse // if status code is 419ServerResponse // if status code is 420ServerResponse // if status code is 422ServerResponse // if status code is 423ServerResponse // if status code is 424 ServerResponse // if status code is 500ServerResponse // if status code is 501ServerResponse // if status code is 502ServerResponse // if status code is 503ServerResponse // if status code is 504ServerResponse // if status code is 505ServerResponse // if status code is 507
and also... listeners for error events...
ServerResponse; // if status code greather than 400ServerResponse; // remove all listeners for an event, the events is an array of status codes or the string 'response_error'
License
The MIT License (MIT)
Copyright (c) 2015 Federico Scarpa <fedescarpa@gmail.com>.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.