1.0.1 • Published 8 years ago

http-status-series v1.0.1

Weekly downloads
3
License
BSD-2-Clause
Repository
github
Last release
8 years ago

HTTP Status Series

A simple utility for checking HTTP status codes.

Inspired by HttpStatus in the Spring Framework.

Install

npm install http-status-series

API

Constants

ConstantValue
INFORMATIONAL1
SUCCESSFUL2
REDIRECTION3
CLIENT_ERROR4
SERVER_ERROR5

Methods

getSeries(statusCode)

Returns the series of the statusCode.

Example
httpStatus.getSeries(200) => 2

isInformational(statusCode)

Returns true if the HTTP status series is informational (1XX).

Example
httpStatus.isInformational(100)   => true
httpStatus.isInformational("100") => true
httpStatus.isInformational(200)   => false
httpStatus.isInformational("200") => false

isSuccessful(statusCode)

Returns true if the HTTP status series is successful (2XX).

Example
httpStatus.isSuccessful(200)   => true
httpStatus.isSuccessful("200") => true
httpStatus.isSuccessful(301)   => false
httpStatus.isSuccessful("301") => false

isRedirection(statusCode)

Returns true if the HTTP status series is a redirection (3XX).

Example
httpStatus.isRedirection(301)   => true
httpStatus.isRedirection("301") => true
httpStatus.isRedirection(404)   => false
httpStatus.isRedirection("404") => false

isClientError(statusCode)

Returns true if the HTTP status series is a client error (4XX).

Example
httpStatus.isClientError(404)   => true
httpStatus.isClientError("404") => true
httpStatus.isClientError(500)   => false
httpStatus.isClientError("500") => false

isServerError(statusCode)

Returns true if the HTTP status series is a server error (5XX).

Example
httpStatus.isServerError(500)   => true
httpStatus.isServerError("500") => true
httpStatus.isServerError(404)   => false
httpStatus.isServerError("404") => false

License

HTTP Status Series is licensed with The BSD 2-Clause License