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.

68 lines (67 loc) 4.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SERVER_ERROR_CODES = exports.CLIENT_ERROR_CODES = exports.REDIRECTION_CODES = exports.SUCCESS_CODES = exports.INFORMATIONAL_CODES = exports.ClassTypes = exports.ClassLimits = exports.HTTP_STATUS_DESCRIPTION = exports.HTTP_STATUS_CODES = exports.HTTP_STATUS_NAMES = exports.HTTP_STATUS_MAPPINGS = exports.CODES = void 0; var codes_constant_1 = require("./codes.constant"); Object.defineProperty(exports, "CODES", { enumerable: true, get: function () { return codes_constant_1.CODES; } }); var http_status_codes_constant_1 = require("./http-status-codes.constant"); Object.defineProperty(exports, "HTTP_STATUS_MAPPINGS", { enumerable: true, get: function () { return http_status_codes_constant_1.HTTP_STATUS_MAPPINGS; } }); var class_limit_constant_1 = require("./class-limit.constant"); Object.defineProperty(exports, "ClassLimits", { enumerable: true, get: function () { return class_limit_constant_1.ClassLimits; } }); Object.defineProperty(exports, "ClassTypes", { enumerable: true, get: function () { return class_limit_constant_1.ClassTypes; } }); var index_1 = require("../utils/mappers/index"); /** * A mapping of HTTP status codes to their respective status names. * @constant {IHttpStatusNames} HTTP_STATUS_NAMES - A mapping of HTTP status codes to their respective status names. * @type {Object<number, string>} */ var HTTP_STATUS_NAMES = (0, index_1.mapCodesToNames)(http_status_codes_constant_1.HTTP_STATUS_MAPPINGS); exports.HTTP_STATUS_NAMES = HTTP_STATUS_NAMES; /** * A mapping of HTTP status names to their respective status codes. * @constant {IHttpStatusCodes} HTTP_STATUS_CODES - A mapping of HTTP status names to their respective status codes. * @type {Object<string, number>} */ var HTTP_STATUS_CODES = (0, index_1.mapNamesToCodes)(http_status_codes_constant_1.HTTP_STATUS_MAPPINGS); exports.HTTP_STATUS_CODES = HTTP_STATUS_CODES; /** * A mapping of HTTP status codes to their respective status descriptions. * @constant {IHttpStatusDescriptions} HTTP_STATUS_DESCRIPTION - A mapping of HTTP status codes to their respective status descriptions. * @type {Object<number, string>} */ var HTTP_STATUS_DESCRIPTION = (0, index_1.mapCodesToDescriptions)(http_status_codes_constant_1.HTTP_STATUS_MAPPINGS); exports.HTTP_STATUS_DESCRIPTION = HTTP_STATUS_DESCRIPTION; /** * A List of all the informational HTTP status codes. * @constant {IHttpStatusDescriptions} INFORMATIONAL_CODES - A List of all the informational HTTP status codes. * @type {number[]} */ var INFORMATIONAL_CODES = (0, index_1.listCodes)(class_limit_constant_1.ClassLimits, codes_constant_1.CODES, class_limit_constant_1.ClassTypes.INFORMATIONAL); exports.INFORMATIONAL_CODES = INFORMATIONAL_CODES; /** * A List of all the success HTTP status codes. * @constant {IHttpStatusDescriptions} SUCCESS_CODES - A List of all the success HTTP status codes. * @type {number[]} */ var SUCCESS_CODES = (0, index_1.listCodes)(class_limit_constant_1.ClassLimits, codes_constant_1.CODES, class_limit_constant_1.ClassTypes.SUCCESS); exports.SUCCESS_CODES = SUCCESS_CODES; /** * A List of all the redirection HTTP status codes. * @constant {IHttpStatusDescriptions} REDIRECTION_CODES - A List of all the redirection HTTP status codes. * @type {number[]} */ var REDIRECTION_CODES = (0, index_1.listCodes)(class_limit_constant_1.ClassLimits, codes_constant_1.CODES, class_limit_constant_1.ClassTypes.REDIRECTION); exports.REDIRECTION_CODES = REDIRECTION_CODES; /** * A List of all the client side error HTTP status codes. * @constant {IHttpStatusDescriptions} CLIENT_SIDE_ERROR_CODES - A List of all the client side error HTTP status codes. * @type {number[]} */ var CLIENT_ERROR_CODES = (0, index_1.listCodes)(class_limit_constant_1.ClassLimits, codes_constant_1.CODES, class_limit_constant_1.ClassTypes.CLIENT_ERROR); exports.CLIENT_ERROR_CODES = CLIENT_ERROR_CODES; /** * A List of all the server side error HTTP status codes. * @constant {IHttpStatusDescriptions} SERVER_ERROR_CODES - A List of all the server side error HTTP status codes. * @type {number[]} */ var SERVER_ERROR_CODES = (0, index_1.listCodes)(class_limit_constant_1.ClassLimits, codes_constant_1.CODES, class_limit_constant_1.ClassTypes.SERVER_ERROR); exports.SERVER_ERROR_CODES = SERVER_ERROR_CODES;