Skip to content

Releases: Skillnter/http-response-status-code

Introduce Utility Toolset

11 Jan 11:57
29a36df
Compare
Choose a tag to compare

Toolset Overview

1. Get Status Code

Returns the HTTP status code from status code name.

Parameters

  • name (String): The name of the status code.

Returns

  • code (number): The code number of the status if successful.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getStatusCode("IM_A_TEAPOT")); // 418

2. Get Status Name

Returns the HTTP status code name from status code.

Parameters

  • code (number): The code number of the status.

Returns

  • name (String): The name of the status code if successful.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getStatusName(418)); // "IM_A_TEAPOT"

3. Get Status Description

Returns the status description from HTTP status code.

Parameters

  • code (number): The code number of the status.

Returns

  • name (String): The description of the status code if successful.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getStatusDescription(500)); // "Internal Server Error"

4. Informational Code Check

Determines whether the specified status code represents an informational status.

Parameters

  • code (number): The code number of the status.

Returns

  • result (boolean): True if the status code is informational, false otherwise.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.isInformational(100)); // True
console.log(STATUS_CODES.isInformational(200)); // False

5. List Informational Codes

Returns all the informational HTTP status codes.

Returns

  • result (number[]): An array of all the informational HTTP status codes.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getInformationalCodes()); // [100, 101, ...]

6. Success Code Check

Determines whether the specified status code represents a success status.

Parameters

  • code (number): The code number of the status.

Returns

  • result (boolean): True if the status code is success status, false otherwise.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.isSuccess(200)); // True
console.log(STATUS_CODES.isSuccess(100)); // False

7. List Success Codes

Returns all the success HTTP status codes.

Returns

  • result (number[]): An array of all the success HTTP status codes.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getSuccessCodes()); // [200, 201, ...]

8. Redirectional Code Check

Determines whether the specified status code represents a redirectional status.

Parameters

  • code (number): The code number of the status.

Returns

  • result (boolean): True if the status code is redirectional status, false otherwise.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.isRedirectional(300)); // True
console.log(STATUS_CODES.isRedirectional(100)); // False

9. List Redirectional Codes

Returns all the redirectional HTTP status codes.

Returns

  • result (number[]): An array of all the redirectional HTTP status codes.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getRedirectionalCodes()); // [300, 301, ...]

10. Client Error Code Check

Determines whether the specified status code represents a client side error status.

Parameters

  • code (number): The code number of the status.

Returns

  • result (boolean): True if the status code is client side error status, false otherwise.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.isClientError(400)); // True
console.log(STATUS_CODES.isClientError(100)); // False

11. List Client Side Error Codes

Returns all the client side error HTTP status codes.

Returns

  • result (number[]): An array of all the client side error HTTP status codes.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getClientErrorCodes()); // [400, 401, ...]

12. Server Error Code Check

Determines whether the specified status code represents a server side error status.

Parameters

  • code (number): The code number of the status.

Returns

  • result (boolean): True if the status code is server side error status, false otherwise.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.isServerError(500)); // True
console.log(STATUS_CODES.isServerError(100)); // False

13. List Server Side Error Codes

Returns all the server side error HTTP status codes.

Returns

  • result (number[]): An array of all the server side error HTTP status codes.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.getServerErrorCodes()); // [500, 501, ...]

14. Valid Code Check

Validates whether the provided status code is recognized as valid.

Parameters

  • code (number): The code number of the status.

Returns

  • result (boolean): True if the status code is valid status, false otherwise.
  • Error: An error object if something goes wrong, containing details about the issue.

Example (Stackblitz)

var STATUS_CODES = require('http-response-status-code');
console.log(STATUS_CODES.isValidStatusCode(500)); // True
console.log(STATUS_CODES.isValidStatusCode(999)); // False

version 1.6.1

06 Apr 16:31
Compare
Choose a tag to compare

SANITIZE CODE AND REMOVE UNNECESSARY FILES

  • Removed release-package.yml file

  • Added CODE_OF_CONDUCT.md file

  • Updated README.md file to fix the typo in code snippet

  • Replaced single quotes with double quotes in files index.ts &
    index-spec.js

  • Updated version number to 1.6.1

v.1.6.0

01 Feb 19:58
cbb2d88
Compare
Choose a tag to compare

What's Changed

Full Changelog: 1.5.3...1.6.0

v1.5.3

13 Nov 21:24
691e20d
Compare
Choose a tag to compare
Merge pull request #7 from Skillnter/dev

TYPO FIX