Skip to content

Commit

Permalink
feat: Add HttpStatusCodes object to const.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Mohammad Honarvar <honarvar.info@gmail.com>
  • Loading branch information
alimd and mohammadhonarvar committed Sep 10, 2024
1 parent eb9cf06 commit 76436bc
Showing 1 changed file with 329 additions and 0 deletions.
329 changes: 329 additions & 0 deletions packages/api-server/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,332 @@ export const HttpMethods = {
PATCH: 'PATCH'
} as const;

/**
* Object representing standard HTTP status codes.
*/
export const HttpStatusCodes = {
/**
* 100 Continue: The server has received the request headers and the client should proceed to send the request body.
*/
Info_100_Continue: 100,

/**
* 101 Switching Protocols: The server understands and is willing to comply with the clients request to switch protocols.
*/
Info_101_Switching_Protocols: 101,

/**
* 102 Processing: The server has received and is processing the request, but no response is available yet.
*/
Info_102_Processing: 102,

/**
* 103 Early Hints: The server is sending some response headers before the final HTTP message.
*/
Info_103_Early_Hints: 103,

/**
* 200 OK: The request has succeeded.
*/
Success_200_OK: 200,

/**
* 201 Created: The request has been fulfilled and resulted in a new resource being created.
*/
Success_201_Created: 201,

/**
* 202 Accepted: The request has been accepted for processing, but the processing has not been completed.
*/
Success_202_Accepted: 202,

/**
* 203 Non-Authoritative Information: The server is a transforming proxy that received a 200 OK
* from the origin server but is returning a modified version of the origins response.
*/
Success_203_Non_Authoritative_Information: 203,

/**
* 204 No Content: The server successfully processed the request and is not returning any content.
*/
Success_204_No_Content: 204,

/**
* 205 Reset Content: The server successfully processed the request,
* asks that the client reset its document view, and is not returning any content.
*/
Success_205_Reset_Content: 205,

/**
* 206 Partial Content: The server is delivering only part of the resource due to a range header sent by the client.
*/
Success_206_Partial_Content: 206,

/**
* 207 Multi-Status: The message body that follows is an XML message
* and can contain a number of separate response codes, depending on how many sub-requests were made.
*/
Success_207_Multi_Status: 207,

/**
* 208 Already Reported: The members of a DAV binding have already been enumerated
* in a preceding part of the (multi-status) response, and are not being included again.
*/
Success_208_Already_Reported: 208,

/**
* 226 IM Used: The server has fulfilled a request for the resource, and the response is a representation
* of the result of one or more instance-manipulations applied to the current instance.
*/
Success_226_IM_Used: 226,

/**
* 300 Multiple Choices: The request has more than one possible response.
*/
Redirect_300_Multiple_Choices: 300,

/**
* 301 Moved Permanently: The URL of the requested resource has been changed permanently.
*/
Redirect_301_Moved_Permanently: 301,

/**
* 302 Found: The URL of the requested resource has been changed temporarily.
*/
Redirect_302_Found: 302,

/**
* 303 See Other: The response to the request can be found under another URI using a GET method.
*/
Redirect_303_See_Other: 303,

/**
* 304 Not Modified: The resource has not been modified since the version specified
* by the request headers If-Modified-Since or If-None-Match.
*/
Redirect_304_Not_Modified: 304,

/**
* 305 Use Proxy: The requested resource is only available through a proxy, the address for which is provided in the response.
*/
Redirect_305_Use_Proxy: 305,

/**
* 306 Switch Proxy: No longer used. Originally meant "Subsequent requests should use the specified proxy."
*/
Redirect_306_Switch_Proxy: 306,

/**
* 307 Temporary Redirect: The server sends this response to direct the client
* to get the requested resource at another URI with the same method that was used in the prior request.
*/
Redirect_307_Temporary_Redirect: 307,

/**
* 308 Permanent Redirect: This means that the resource is now permanently located at another URI,
* specified by the Location: HTTP Response header.
*/
Redirect_308_Permanent_Redirect: 308,

/**
* 400 Bad Request: The server cannot or will not process the request due to something that is perceived to be a client error.
*/
Error_Client_400_Bad_Request: 400,

/**
* 401 Unauthorized: The request has not been applied because it lacks valid authentication credentials for the target resource.
*/
Error_Client_401_Unauthorized: 401,

/**
* 402 Payment Required: Reserved for future use.
*/
Error_Client_402_Payment_Required: 402,

/**
* 403 Forbidden: The client does not have access rights to the content, so the server is refusing to give the requested resource.
*/
Error_Client_403_Forbidden: 403,

/**
* 404 Not Found: The server can not find the requested resource.
*/
Error_Client_404_Not_Found: 404,

/**
* 405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.
*/
Error_Client_405_Method_Not_Allowed: 405,

/**
* 406 Not Acceptable: The target resource does not have a current representation that would be acceptable
* to the user agent, according to the proactive negotiation header fields received in the request,
* and the server is unwilling to supply a default representation.
*/
Error_Client_406_Not_Acceptable: 406,

/**
* 407 Proxy Authentication Required: Similar to 401 Unauthorized,
* but it indicates that the client needs to authenticate itself in order to use a proxy.
*/
Error_Client_407_Proxy_Authentication_Required: 407,

/**
* 408 Request Timeout: The server timed out waiting for the request.
*/
Error_Client_408_Request_Timeout: 408,

/**
* 409 Conflict: The request could not be processed because of conflict in the request, such as an edit conflict.
*/
Error_Client_409_Conflict: 409,

/**
* 410 Gone: The requested resource is no longer available and will not be available again.
*/
Error_Client_410_Gone: 410,

/**
* 411 Length Required: The server refuses to accept the request without a defined Content-Length header.
*/
Error_Client_411_Length_Required: 411,

/**
* 412 Precondition Failed: One or more conditions given in the request header fields evaluated to false when tested on the server.
*/
Error_Client_412_Precondition_Failed: 412,

/**
* 413 Payload Too Large: The server is refusing to process a request because the request payload is larger
* than the server is willing or able to process.
*/
Error_Client_413_Payload_Too_Large: 413,

/**
* 414 URI Too Long: The server is refusing to service the request because the URI is longer than the server is willing to interpret.
*/
Error_Client_414_URI_Too_Long: 414,

/**
* 415 Unsupported Media Type: The server is refusing to service the request
* because the entity of the request is in a format not supported by the requested resource for the requested method.
*/
Error_Client_415_Unsupported_Media_Type: 415,

/**
* 416 Range Not Satisfiable: The client has asked for a portion of the file, but the server cannot supply that portion.
*/
Error_Client_416_Range_Not_Satisfiable: 416,

/**
* 417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.
*/
Error_Client_417_Expectation_Failed: 417,

/**
* 421 Misdirected Request: The request was directed at a server that is not able to produce a response.
*/
Error_Client_421_Misdirected_Request: 421,

/**
* 422 Unprocessable Entity: The request was well-formed but was unable to be followed due to semantic errors.
*/
Error_Client_422_Unprocessable_Entity: 422,

/**
* 423 Locked: The resource that is being accessed is locked.
*/
Error_Client_423_Locked: 423,

/**
* 424 Failed Dependency: The request failed due to a failure of a previous request.
*/
Error_Client_424_Failed_Dependency: 424,

/**
* 425 Too Early: The server is unwilling to risk processing a request that might be replayed.
*/
Error_Client_425_Too_Early: 425,

/**
* 426 Upgrade Required: The server refuses to perform the request using the current protocol
* but might be willing to do so after the client upgrades to a different protocol.
*/
Error_Client_426_Upgrade_Required: 426,

/**
* 428 Precondition Required: The origin server requires the request to be conditional.
*/
Error_Client_428_Precondition_Required: 428,

/**
* 429 Too Many Requests: The user has sent too many requests in a given amount of time ("rate limiting").
*/
Error_Client_429_Too_Many_Requests: 429,

/**
* 431 Request Header Fields Too Large: The server is unwilling to process the request because its header fields are too large.
*/
Error_Client_431_Request_Header_Fields_Too_Large: 431,

/**
* 451 Unavailable For Legal Reasons: The user requests an illegal resource, such as a web page censored by a government.
*/
Error_Client_451_Unavailable_For_Legal_Reasons: 451,

/**
* 500 Internal Server Error: A generic error message, given when no more specific message is suitable.
*/
Error_Server_500_Internal_Server_Error: 500,

/**
* 501 Not Implemented: The server either does not recognize the request method, or it lacks the ability to fulfill the request.
*/
Error_Server_501_Not_Implemented: 501,

/**
* 502 Bad Gateway: The server was acting as a gateway or proxy and received an invalid response from the upstream server.
*/
Error_Server_502_Bad_Gateway: 502,

/**
* 503 Service Unavailable: The server is currently unavailable (because it is overloaded or down for maintenance).
*/
Error_Server_503_Service_Unavailable: 503,

/**
* 504 Gateway Timeout: The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
*/
Error_Server_504_Gateway_Timeout: 504,

/**
* 505 HTTP Version Not Supported: The server does not support the HTTP protocol version used in the request.
*/
Error_Server_505_HTTP_Version_Not_Supported: 505,

/**
* 506 Variant Also Negotiates: Transparent content negotiation for the request results in a circular reference.
*/
Error_Server_506_Variant_Also_Negotiates: 506,

/**
* 507 Insufficient Storage: The server is unable to store the representation needed to complete the request.
*/
Error_Server_507_Insufficient_Storage: 507,

/**
* 508 Loop Detected: The server detected an infinite loop while processing the request.
*/
Error_Server_508_Loop_Detected: 508,

/**
* 510 Not Extended: Further extensions to the request are required for the server to fulfill it.
*/
Error_Server_510_Not_Extended: 510,

/**
* 511 Network Authentication Required: The client needs to authenticate to gain network access.
*/
Error_Server_511_Network_Authentication_Required: 511
} as const;

0 comments on commit 76436bc

Please sign in to comment.