belgattitude/httpx

View on GitHub
packages/exception/src/status/index.ts

Summary

Maintainability
A
0 mins
Test Coverage
/* eslint-disable @typescript-eslint/naming-convention */
import {
  HttpBadRequest,
  HttpConflict,
  HttpExpectationFailed,
  HttpFailedDependency,
  HttpForbidden,
  HttpGone,
  HttpImATeapot,
  HttpLengthRequired,
  HttpLocked,
  HttpMethodNotAllowed,
  HttpMisdirectedRequest,
  HttpNotAcceptable,
  HttpNotFound,
  HttpPayloadTooLarge,
  HttpPaymentRequired,
  HttpPreconditionFailed,
  HttpPreconditionRequired,
  HttpProxyAuthenticationRequired,
  HttpRangeNotSatisfiable,
  HttpRequestHeaderFieldsTooLarge,
  HttpRequestTimeout,
  HttpTooEarly,
  HttpTooManyRequests,
  HttpUnauthorized,
  HttpUnavailableForLegalReasons,
  HttpUnprocessableEntity,
  HttpUnsupportedMediaType,
  HttpUpgradeRequired,
  HttpUriTooLong,
} from '../client';
import {
  HttpBadGateway,
  HttpGatewayTimeout,
  HttpInsufficientStorage,
  HttpInternalServerError,
  HttpLoopDetected,
  HttpNetworkAuthenticationRequired,
  HttpNotExtended,
  HttpNotImplemented,
  HttpServiceUnavailable,
  HttpVariantAlsoNegotiates,
  HttpVersionNotSupported,
} from '../server';

export const statusMap = {
  400: HttpBadRequest,
  401: HttpUnauthorized,
  402: HttpPaymentRequired,
  403: HttpForbidden,
  404: HttpNotFound,
  405: HttpMethodNotAllowed,
  406: HttpNotAcceptable,
  407: HttpProxyAuthenticationRequired,
  408: HttpRequestTimeout,
  409: HttpConflict,
  410: HttpGone,
  411: HttpLengthRequired,
  412: HttpPreconditionFailed,
  413: HttpPayloadTooLarge,
  414: HttpUriTooLong,
  415: HttpUnsupportedMediaType,
  416: HttpRangeNotSatisfiable,
  417: HttpExpectationFailed,
  418: HttpImATeapot,
  421: HttpMisdirectedRequest,
  422: HttpUnprocessableEntity,
  423: HttpLocked,
  424: HttpFailedDependency,
  425: HttpTooEarly,
  426: HttpUpgradeRequired,
  428: HttpPreconditionRequired,
  429: HttpTooManyRequests,
  431: HttpRequestHeaderFieldsTooLarge,
  451: HttpUnavailableForLegalReasons,
  500: HttpInternalServerError,
  501: HttpNotImplemented,
  502: HttpBadGateway,
  503: HttpServiceUnavailable,
  504: HttpGatewayTimeout,
  505: HttpVersionNotSupported,
  506: HttpVariantAlsoNegotiates,
  507: HttpInsufficientStorage, // webdav
  508: HttpLoopDetected, // webdav
  // Well-known (unassigned by ietf https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
  // 509: 'BandwidthLimitExceeded',
  510: HttpNotExtended,
  511: HttpNetworkAuthenticationRequired,
  // Well-known Cloudflare (unassigned by ietf https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
  /*
  520: 'Unknown Error',
  521: 'Web Server Is Down',
  522: 'Connection Timed Out',
  523: 'Origin Is Unreachable',
  524: 'A Timeout Occurred',
  525: 'SSL Handshake Failed',
  526: 'Invalid SSL Certificate',
   */
};