1.0.1 • Published 6 years ago

http-status-js v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

http-status-codes

Globally usable HTTP status codes.

All codes are globally define in HttpStatus and bifurcated by it's use in HttpStatusFor

Categories in HttpStatusFor are :

* `INFORMATIONAL` starts with 1**
* `SUCCESS` Starts with 2**
* `REDIRECTION` Starts with 3**
* `CLIENT_ERROR` Starts with 4**
* `SERVER_ERROR` Starts with 5**

Usage (Ex. express 4.x)

//Require once and use anywhere in app
require('http-status-js');

response
	.status(HttpStatus.OK.code) //returns 200 code
	.send(HttpStatus.OK.text);

response
	.status(HttpStatusFor.SERVER_ERROR.INTERNAL_SERVER_ERROR.code)
	.send({
		error: HttpStatusFor.SERVER_ERROR.INTERNAL_SERVER_ERROR.text)
	});

Codes

ConstantCodeText
CONTINUE100Continue
SWITCHING_PROTOCOLS101Switching Protocols
PROCESSING102Processing
OK200OK
CREATED201Created
ACCEPTED202Accepted
NON_AUTHORITATIVE_INFORMATION203Non Authoritative Information
NO_CONTENT204No Content
RESET_CONTENT205Reset Content
PARTIAL_CONTENT206Partial Content
MULTI207Multi-Status
ALREADY_REPORTED208Already Reported
IM_USED226IM Used
MULTIPLE_CHOICES300Multiple Choices
MOVED_PERMANENTLY301Moved Permanently
FOUND302Found
SEE_OTHER303See Other
NOT_MODIFIED304Not Modified
USE_PROXY305Use Proxy
TEMPORARY_REDIRECT307Temporary Redirect
PERMANENT_REDIRECT308Permanent Redirect
BAD_REQUEST400Bad Request
UNAUTHORIZED401Unauthorized
PAYMENT_REQUIRED402Payment Required
FORBIDDEN403Forbidden
NOT_FOUND404Not Found
METHOD_NOT_ALLOWED405Method Not Allowed
NOT_ACCEPTABLE406Not Acceptable
PROXY_AUTHENTICATION_REQUIRED407Proxy Authentication Required
REQUEST_TIMEOUT408Request Timeout
CONFLICT409Conflict
GONE410Gone
LENGTH_REQUIRED411Length Required
PRECONDITION_FAILED412Precondition Failed
Payload_Too_Large413Payload Too Large
Request_URI_Too_Long414Request URI Too Long
Unsupported_Media_Type415Unsupported Media Type
Requested_Range_Not_Satisfiable416Requested Range Not Satisfiable
Expectation_Failed417Expectation Failed
I418I'm a teapot
Misdirected_Request421Misdirected Request
UNPROCESSABLE_ENTITY422Unprocessable Entity
LOCKED423Locked
FAILED_DEPENDENCY424Failed Dependency
UPGRADE_REQUIRED426Upgrade Required
PRECONDITION_REQUIRED428Precondition Required
TOO_MANY_REQUESTS429Too Many Requests
REQUEST_HEADER_FIELDS_TOO_LARGE431Request Header Fields Too Large
CONNECTION_CLOSED_WITHOUT_RESPONSE444Connection Closed Without Response
UNAVAILABLE_FOR_LEGAL_REASONS451Unavailable For Legal Reasons
CLIENT_CLOSED_REQUEST499Client Closed Request
INTERNAL_SERVER_ERROR500Internal Server Error
NOT_IMPLEMENTED501Not Implemented
BAD_GATEWAY502Bad Gateway
SERVICE_UNAVAILABLE503Service Unavailable
GATEWAY_TIMEOUT504Gateway Timeout
HTTP_VERSION_NOT_SUPPORTED505HTTP Version Not Supported
VARIANT_ALSO_NEGOTIATES506Variant Also Negotiates
INSUFFICIENT_STORAGE507Insufficient Storage
LOOP_DETECTED508Loop Detected
NOT_EXTENDED510Not Extended
NETWORK_AUTHENTICATION_REQUIRED511Network Authentication Required
NETWORK_CONNECT_TIMEOUT_ERROR599Network Connect Timeout Error