UNPKG

@catbee/utils

Version:

A modular, production-grade utility toolkit for Node.js and TypeScript, designed for robust, scalable applications (including Express-based services). All utilities are tree-shakable and can be imported independently.

275 lines 12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpStatusCodes = void 0; /** * Complete HTTP status codes enum with descriptions. * For use with API responses and error handling. */ var HttpStatusCodes; (function (HttpStatusCodes) { // 1xx Informational /** * The server has received the request headers and the client should proceed to send the request body. */ HttpStatusCodes[HttpStatusCodes["CONTINUE"] = 100] = "CONTINUE"; /** * The server is switching protocols according to the client's request. */ HttpStatusCodes[HttpStatusCodes["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS"; /** * Server has received the request and is still processing it. */ HttpStatusCodes[HttpStatusCodes["PROCESSING"] = 102] = "PROCESSING"; /** * The server is sending preliminary headers while preparing the final response. */ HttpStatusCodes[HttpStatusCodes["EARLY_HINTS"] = 103] = "EARLY_HINTS"; // 2xx Success /** * The request succeeded. The result meaning depends on the HTTP method used. */ HttpStatusCodes[HttpStatusCodes["OK"] = 200] = "OK"; /** * The request succeeded and a new resource was created as a result. */ HttpStatusCodes[HttpStatusCodes["CREATED"] = 201] = "CREATED"; /** * The request has been received but not yet acted upon. */ HttpStatusCodes[HttpStatusCodes["ACCEPTED"] = 202] = "ACCEPTED"; /** * The returned information is from a third-party source, not the origin server. */ HttpStatusCodes[HttpStatusCodes["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION"; /** * The request succeeded but there's no content to send in the response. */ HttpStatusCodes[HttpStatusCodes["NO_CONTENT"] = 204] = "NO_CONTENT"; /** * The client should reset the document view that caused this request. */ HttpStatusCodes[HttpStatusCodes["RESET_CONTENT"] = 205] = "RESET_CONTENT"; /** * The server is delivering only part of the resource due to a range header sent by the client. */ HttpStatusCodes[HttpStatusCodes["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT"; /** * Conveys information about multiple resources, for complex operations. */ HttpStatusCodes[HttpStatusCodes["MULTI_STATUS"] = 207] = "MULTI_STATUS"; /** * The members of a DAV binding have already been enumerated and are not included in the response. */ HttpStatusCodes[HttpStatusCodes["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED"; /** * The server has fulfilled a request for the resource, and the response represents the result of one or more instance-manipulations. */ HttpStatusCodes[HttpStatusCodes["IM_USED"] = 226] = "IM_USED"; // 3xx Redirection /** * The request has more than one possible response and the client should choose one. */ HttpStatusCodes[HttpStatusCodes["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES"; /** * The resource has been permanently moved to a new URL. */ HttpStatusCodes[HttpStatusCodes["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY"; /** * The resource has been temporarily moved to another URL. */ HttpStatusCodes[HttpStatusCodes["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY"; /** * The response to the request can be found under another URI using the GET method. */ HttpStatusCodes[HttpStatusCodes["SEE_OTHER"] = 303] = "SEE_OTHER"; /** * The resource hasn't been modified since the last request. */ HttpStatusCodes[HttpStatusCodes["NOT_MODIFIED"] = 304] = "NOT_MODIFIED"; /** * @deprecated * Response must be accessed through a proxy. */ HttpStatusCodes[HttpStatusCodes["USE_PROXY"] = 305] = "USE_PROXY"; /** * The resource is temporarily available at a different URI, using the same HTTP method. */ HttpStatusCodes[HttpStatusCodes["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT"; /** * The resource has been permanently moved to another URL, using the same HTTP method. */ HttpStatusCodes[HttpStatusCodes["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT"; // 4xx Client Error /** * The server cannot process the request due to a client error (malformed request). */ HttpStatusCodes[HttpStatusCodes["BAD_REQUEST"] = 400] = "BAD_REQUEST"; /** * Authentication is required and has failed or not been provided. */ HttpStatusCodes[HttpStatusCodes["UNAUTHORIZED"] = 401] = "UNAUTHORIZED"; /** * Reserved for future use, originally intended for digital payment systems. */ HttpStatusCodes[HttpStatusCodes["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED"; /** * The client doesn't have permission to access the requested resource. */ HttpStatusCodes[HttpStatusCodes["FORBIDDEN"] = 403] = "FORBIDDEN"; /** * The requested resource could not be found on the server. */ HttpStatusCodes[HttpStatusCodes["NOT_FOUND"] = 404] = "NOT_FOUND"; /** * The request method is not supported for the requested resource. */ HttpStatusCodes[HttpStatusCodes["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED"; /** * The server can't provide a response matching the list of acceptable values in the client's headers. */ HttpStatusCodes[HttpStatusCodes["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE"; /** * Authentication by a proxy is required. */ HttpStatusCodes[HttpStatusCodes["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED"; /** * The server timed out waiting for the request. */ HttpStatusCodes[HttpStatusCodes["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT"; /** * The request conflicts with the current state of the server. */ HttpStatusCodes[HttpStatusCodes["CONFLICT"] = 409] = "CONFLICT"; /** * The resource has been permanently deleted with no forwarding address. */ HttpStatusCodes[HttpStatusCodes["GONE"] = 410] = "GONE"; /** * The server requires a Content-Length header field. */ HttpStatusCodes[HttpStatusCodes["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED"; /** * Preconditions in the client's headers failed. */ HttpStatusCodes[HttpStatusCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED"; /** * Request entity is larger than limits defined by server. */ HttpStatusCodes[HttpStatusCodes["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG"; /** * The request payload exceeds server size limits. * Modern equivalent of REQUEST_TOO_LONG. */ HttpStatusCodes[HttpStatusCodes["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE"; /** * The URI requested is too long for the server to interpret. */ HttpStatusCodes[HttpStatusCodes["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG"; /** * The server does not support the media type requested by the client. */ HttpStatusCodes[HttpStatusCodes["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE"; /** * The range specified by the Range header cannot be fulfilled. */ HttpStatusCodes[HttpStatusCodes["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE"; /** * The server cannot meet the expectations given in the Expect header. */ HttpStatusCodes[HttpStatusCodes["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED"; /** * The server refuses to brew coffee because it is a teapot. (April Fools' joke) */ HttpStatusCodes[HttpStatusCodes["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT"; /** * The server cannot store the representation needed to complete the request. */ HttpStatusCodes[HttpStatusCodes["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE"; /** * @deprecated * A method has failed - specific to Spring Framework. */ HttpStatusCodes[HttpStatusCodes["METHOD_FAILURE"] = 420] = "METHOD_FAILURE"; /** * The server cannot produce a response for the requested URI scheme and authority. */ HttpStatusCodes[HttpStatusCodes["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST"; /** * The request was well-formed but has semantic errors preventing processing. */ HttpStatusCodes[HttpStatusCodes["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY"; /** * The requested resource is locked against access. */ HttpStatusCodes[HttpStatusCodes["LOCKED"] = 423] = "LOCKED"; /** * The request failed due to the failure of a previous request. */ HttpStatusCodes[HttpStatusCodes["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY"; /** * The client should switch to a different protocol. */ HttpStatusCodes[HttpStatusCodes["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED"; /** * The server requires conditional requests to prevent lost updates. */ HttpStatusCodes[HttpStatusCodes["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED"; /** * The client has sent too many requests in a given time period (rate limiting). */ HttpStatusCodes[HttpStatusCodes["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS"; /** * Request headers are too large for the server to process. */ HttpStatusCodes[HttpStatusCodes["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE"; /** * Resource cannot be legally provided (e.g., censored by government). */ HttpStatusCodes[HttpStatusCodes["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS"; // 5xx Server Error /** * The server encountered an unexpected error preventing it from fulfilling the request. */ HttpStatusCodes[HttpStatusCodes["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR"; /** * The server does not support the functionality required to fulfill the request. */ HttpStatusCodes[HttpStatusCodes["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED"; /** * The server, acting as a gateway, received an invalid response from an upstream server. */ HttpStatusCodes[HttpStatusCodes["BAD_GATEWAY"] = 502] = "BAD_GATEWAY"; /** * The server is currently unable to handle the request due to temporary overload or maintenance. */ HttpStatusCodes[HttpStatusCodes["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE"; /** * The server, acting as a gateway, did not receive a timely response from an upstream server. */ HttpStatusCodes[HttpStatusCodes["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT"; /** * The server does not support the HTTP protocol version used in the request. */ HttpStatusCodes[HttpStatusCodes["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED"; /** * Transparent content negotiation for the request resulted in circular reference. */ HttpStatusCodes[HttpStatusCodes["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES"; /** * The server cannot store the representation needed to complete the request. */ HttpStatusCodes[HttpStatusCodes["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE"; /** * The server detected an infinite loop while processing the request. */ HttpStatusCodes[HttpStatusCodes["LOOP_DETECTED"] = 508] = "LOOP_DETECTED"; /** * Further extensions to the request are required for the server to fulfill it. */ HttpStatusCodes[HttpStatusCodes["NOT_EXTENDED"] = 510] = "NOT_EXTENDED"; /** * The client needs to authenticate to gain network access. */ HttpStatusCodes[HttpStatusCodes["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED"; })(HttpStatusCodes || (exports.HttpStatusCodes = HttpStatusCodes = {})); //# sourceMappingURL=http-status-codes.js.map