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.

33 lines (32 loc) 1.99 kB
import { CODES } from "../../constants"; import { IClassLimits, ICodeList, IHttpStatusCodes, IHttpStatusDescriptions, IHttpStatusMappings, IHttpStatusNames } from "../../interfaces"; /** * A mapping of HTTP status codes to their respective status names. * @param {IHttpStatusMappings} httpStatusMappings - The HTTP status code mappings. * @returns {IHttpStatusNames} A mapping of HTTP status codes to their respective status names. * @type {Object<number, string>} */ export declare function mapCodesToNames(httpStatusMappings: IHttpStatusMappings): IHttpStatusNames; /** * A mapping of HTTP status code names to their respective status codes. * @param {IHttpStatusMappings} httpStatusMappings - The HTTP status code mappings. * @returns {IHttpStatusCodes} A mapping of HTTP status code names to their respective status codes. * @type {Object<string, number>} */ export declare function mapNamesToCodes(httpStatusMappings: IHttpStatusMappings): IHttpStatusCodes; /** * A mapping of HTTP status codes to their respective status descriptions. * @param {IHttpStatusMappings} httpStatusMappings - The HTTP status code mappings. * @returns {IHttpStatusDescriptions} A mapping of HTTP status codes to their respective status descriptions. * @type {Object<number, string>} */ export declare function mapCodesToDescriptions(httpStatusMappings: IHttpStatusMappings): IHttpStatusDescriptions; /** * Provides a list of HTTP status codes for a given type. * @param {IClassLimits} classLimits - The class limits for HTTP status codes. * @param {typeof CODES} codesEnum - The enumeration of HTTP status codes. * @param {string} type - The type of HTTP status code to list. * @returns {(ICodeList | Error)} A list of HTTP status codes for the given type, or an error if the type does not exist. * @type {Object<number, string>} */ export declare function listCodes(classLimits: IClassLimits, codesEnum: typeof CODES, type: string): ICodeList | Error;