UNPKG

http-response-status-code

Version:

A lightweight utility for retrieving HTTP status codes, names, and descriptions. Easily validate, categorize, and manage HTTP responses with built-in methods for informational, success, redirection, client, and server error codes.

70 lines (69 loc) 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getServerErrorCodes = exports.getClientErrorCodes = exports.getRedirectionalCodes = exports.getSuccessCodes = exports.getInformationalCodes = void 0; var constants_1 = require("../../constants"); /** * Provides a list of all the informational HTTP status codes. * @name List Informational Codes * @returns {number[]} result - An array of all the informational HTTP status codes. * * @example * var STATUS_CODES = require('http-response-status-code'); * console.log(STATUS_CODES.getInformationalCodes()); // [100, 101, ...] */ function getInformationalCodes() { return constants_1.INFORMATIONAL_CODES; } exports.getInformationalCodes = getInformationalCodes; /** * Provides a list of all the success HTTP status codes. * @name List Success Codes * @returns {number[]} result - An array of all the success HTTP status codes. * * @example * var STATUS_CODES = require('http-response-status-code'); * console.log(STATUS_CODES.getSuccessCodes()); // [200, 201, ...] */ function getSuccessCodes() { return constants_1.SUCCESS_CODES; } exports.getSuccessCodes = getSuccessCodes; /** * Provides a list of all the redirection HTTP status codes. * @name List Redirection Codes * @returns {number[]} result - An array of all the redirection HTTP status codes. * * @example * var STATUS_CODES = require('http-response-status-code'); * console.log(STATUS_CODES.getRedirectionalCodes()); // [300, 301, ...] */ function getRedirectionalCodes() { return constants_1.REDIRECTION_CODES; } exports.getRedirectionalCodes = getRedirectionalCodes; /** * Provides a list of all the client side error HTTP status codes. * @name List Client Side Error Codes * @returns {number[]} result - An array of all the client side error HTTP status codes. * * @example * var STATUS_CODES = require('http-response-status-code'); * console.log(STATUS_CODES.getClientErrorCodes()); // [400, 401, ...] */ function getClientErrorCodes() { return constants_1.CLIENT_ERROR_CODES; } exports.getClientErrorCodes = getClientErrorCodes; /** * Provides a list of all the server side error HTTP status codes. * @name List Server Side Error Codes * @returns {number[]} result - An array of all the server side error HTTP status codes. * * @example * var STATUS_CODES = require('http-response-status-code'); * console.log(STATUS_CODES.getServerErrorCodes()); // [500, 501, ...] */ function getServerErrorCodes() { return constants_1.SERVER_ERROR_CODES; } exports.getServerErrorCodes = getServerErrorCodes;