http-status-range
Check if HTTP status code is within range or is a specific code
Instal
$npm install --save http-status-range
Usage
... async { const r = await if http ... // Code is between 100 and 199 else if http ... // Code is between 200 and 299 else if http ... // Code is between 300 and 399 else if http ... // Code is between 400 and 499 else if http ... // Code is between 500 and 599 OR ifrstatus === ACCEPTED ... else ifrstatus === BAD_GATEWAY ... else ifrstatus === BAD_REQUEST ... else ifrstatus === CONFLICT ... else ifrstatus === CONTINUE ... else ifrstatus === CREATED ... else ifrstatus === EXPECTATION_FAILED ... else ifrstatus === FAILED_DEPENDENCY ... else ifrstatus === FORBIDDEN ... else ifrstatus === GATEWAY_TIMEOUT ... else ifrstatus === GONE ... else ifrstatus === HTTP_VERSION_NOT_SUPPORTED ... else ifrstatus === IM_A_TEAPOT ... else ifrstatus === INSUFFICIENT_SPACE_ON_RESOURCE ... else ifrstatus === INSUFFICIENT_STORAGE ... else ifrstatus === INTERNAL_SERVER_ERROR ... else ifrstatus === LENGTH_REQUIRED ... else ifrstatus === LOCKED ... else ifrstatus === METHOD_FAILURE ... else ifrstatus === METHOD_NOT_ALLOWED ... else ifrstatus === MOVED_PERMANENTLY ... else ifrstatus === MOVED_TEMPORARILY ... else ifrstatus === MULTI_STATUS ... else ifrstatus === MULTIPLE_CHOICES ... else ifrstatus === NETWORK_AUTHENTICATION_REQUIRED ... else ifrstatus === NO_CONTENT ... else ifrstatus === NON_AUTHORITATIVE_INFORMATION ... else ifrstatus === NOT_ACCEPTABLE ... else ifrstatus === NOT_FOUND ... else ifrstatus === NOT_IMPLEMENTED ... else ifrstatus === NOT_MODIFIED ... else ifrstatus === OK ... else ifrstatus === PARTIAL_CONTENT ... else ifrstatus === PAYMENT_REQUIRED ... else ifrstatus === PERMANENT_REDIRECT ... else ifrstatus === PRECONDITION_FAILED ... else ifrstatus === PRECONDITION_REQUIRED ... else ifrstatus === PROCESSING ... else ifrstatus === PROXY_AUTHENTICATION_REQUIRED ... else ifrstatus === REQUEST_HEADER_FIELDS_TOO_LARGE ... else ifrstatus === REQUEST_TIMEOUT ... else ifrstatus === REQUEST_TOO_LONG ... else ifrstatus === REQUEST_URI_TOO_LONG ... else ifrstatus === REQUESTED_RANGE_NOT_SATISFIABLE ... else ifrstatus === RESET_CONTENT ... else ifrstatus === SEE_OTHER ... else ifrstatus === SERVICE_UNAVAILABLE ... else ifrstatus === SWITCHING_PROTOCOLS ... else ifrstatus === TEMPORARY_REDIRECT ... else ifrstatus === TOO_MANY_REQUESTS ... else ifrstatus === UNAUTHORIZED ... else ifrstatus === UNPROCESSABLE_ENTITY ... else ifrstatus === UNSUPPORTED_MEDIA_TYPE ... else ifrstatus === USE_PROXY ... }
Author
José Varela
Contibuting
Just fork this repo and open a PR.