/**
* Object containing all possible HTTP status codes for an API
*/
const API_STATUS_CODES = {
// 1xx Informational
/**
* This interim response indicates that everything so far is OK and
* that the client should continue with the request or ignore it if
* it is already finished.
*/
CONTINUE: 100,
/**
* This code is sent in response to an Upgrade request header by the
* client, and indicates the protocol the server is switching to.
*/
SWITCHING_PROTOCOLS: 101,
/**
* A WebDAV request may contain many sub-requests involving file
* operations, requiring a long time to complete the request.
* This code indicates that the server has received and is processing
* the request, but no response is available yet.
*/
PROCESSING: 102,
// 2xx Success
/**
* The request has succeeded. The information returned with the response
* depends on the method used in the request.
*/
OK: 200,
/**
* The request has been fulfilled, resulting in the creation of a new resource.
*/
CREATED: 201,
/**
* The request has been accepted for processing, but the processing has
* not been completed.
*/
ACCEPTED: 202,
/**
* The server is a transforming proxy that received a 200 OK from its
* origin, but is returning a modified version of the origin's response.
*/
NON_AUTHORITATIVE_INFORMATION: 203,
/**
* The server successfully processed the request and is not returning
* any content.
*/
NO_CONTENT: 204,
/**
* The server successfully processed the request and is not returning
* any content, but requires that the requester reset the document view.
*/
RESET_CONTENT: 205,
/**
* The server is delivering only part of the resource (byte serving)
* due to a range header sent by the client.
*/
PARTIAL_CONTENT: 206,
/**
* A WebDAV request may contain many sub-requests involving file
* operations, requiring a long time to complete the request.
* This code indicates that the response to the request is a list
* of independent responses, one for each sub-request.
*/
MULTI_STATUS: 207,
/**
* The members of a DAV binding have already been enumerated in a
* previous reply to this request, and are not being included again.
*/
ALREADY_REPORTED: 208,
/**
* The server has fulfilled a GET request for the resource, and
* the response is a representation of the result of one or more
* instance-manipulations applied to the current instance.
*/
IM_USED: 226,
// 3xx Redirection
/**
* The requested resource has multiple choices available, each with
* different characteristics.
*/
MULTIPLE_CHOICES: 300,
/**
* The requested resource has been assigned a new permanent URI and
* any future references to this resource should use one of the
* returned URIs.
*/
MOVED_PERMANENTLY: 301,
/**
* The requested resource resides temporarily under a different URI.
*/
FOUND: 302,
/**
* The response to the request can be found under a different URI
* and should be retrieved using a GET HTTP method on that resource.
*/
SEE_OTHER: 303,
/**
* The requested resource has not been modified since the last time
* the client accessed it.
*/
NOT_MODIFIED: 304,
/**
* The requested resource must be accessed through the proxy given by
* the location field.
*/
USE_PROXY: 305,
/**
* The requested resource resides temporarily under a different URI.
*/
TEMPORARY_REDIRECT: 307,
/**
* The requested resource has been permanently moved to a new URI and any
* future references to this resource should use one of the returned URIs.
*/
PERMANENT_REDIRECT: 308,
// 4xx Client Error
/**
* This status code indicates that the server cannot or will not process
* the request due to an apparent client error.
*/
BAD_REQUEST: 400,
/**
* This status code indicates that the request has not been applied because
* it lacks valid authentication credentials for the target resource.
*/
UNAUTHORIZED: 401,
/**
* This status code is reserved for future use.
*/
PAYMENT_REQUIRED: 402,
/**
* This status code indicates that the server understood the request but
* refuses to authorize it.
*/
FORBIDDEN: 403,
/**
* This status code indicates that the server was unable to find the
* requested resource.
*/
NOT_FOUND: 404,
/**
* This status code indicates that the request method is not supported
* for the requested resource.
*/
METHOD_NOT_ALLOWED: 405,
/**
* This status code indicates that the server cannot produce a response
* matching the list of acceptable values defined in the request's proactive
* content negotiation headers.
*/
NOT_ACCEPTABLE: 406,
/**
* This status code is similar to 401 (Unauthorized), but indicates that
* the client must first authenticate itself with the proxy.
*/
PROXY_AUTHENTICATION_REQUIRED: 407,
/**
* This status code indicates that the server did not receive a complete
* request message within the time that it was prepared to wait.
*/
REQUEST_TIMEOUT: 408,
/**
* This status code indicates that the request could not be completed
* due to a conflict with the current state of the target resource.
*/
CONFLICT: 409,
/**
* This status code indicates that the requested resource is no longer
* available and will not be available again.
*/
GONE: 410,
/**
* This status code indicates that the server refuses to accept the
* request without a defined Content-Length.
*/
LENGTH_REQUIRED: 411,
/**
* This status code indicates that one or more conditions given in
* the request header fields evaluated to false when tested on the server.
*/
PRECONDITION_FAILED: 412,
/**
* This status code indicates that the server is refusing to process
* a request because the payload is too large.
*/
PAYLOAD_TOO_LARGE: 413,
/**
* This status code indicates that the server is refusing to service
* the request because the request-target is longer than the server
* is willing to interpret.
*/
URI_TOO_LONG: 414,
/**
* This status code indicates that the server is refusing to service
* the request because the entity of the request is in a format not
* supported by the requested resource.
*/
UNSUPPORTED_MEDIA_TYPE: 415,
/**
* This status code indicates that none of the ranges in the request
* header fields overlap the current extent of the selected resource
* or that the set of ranges requested has been rejected due to invalid
* ranges or an excessive request of small or overlapping ranges.
*/
RANGE_NOT_SATISFIABLE: 416,
/**
* This status code indicates that the expectation given in the Expect
* request header field could not be met by at least one of the inbound
* servers.
*/
EXPECTATION_FAILED: 417,
/**
* This status code is a tongue-in-cheek code returned by some websites
* to indicate that the requested entity is a teapot and thus, is not
* capable of producing coffee.
*/
IM_A_TEAPOT: 418,
/**
* The server is unable to produce a response for a request that appears
* to be valid.
*/
MISDIRECTED_REQUEST: 421,
/**
* The request was well-formed but was unable to be followed due to
* semantic errors.
*/
UNPROCESSABLE_ENTITY: 422,
/**
* The resource that is being accessed is locked.
*/
LOCKED: 423,
/**
* The request failed due to failure of a previous request.
*/
FAILED_DEPENDENCY: 424,
/**
* The server refuses to accept the request because it is too soon
* for the user to retry.
*/
TOO_EARLY: 425,
/**
* The client should switch to a different protocol such as TLS/1.0,
* given in the Upgrade header field.
*/
UPGRADE_REQUIRED: 426,
/**
* The server requires the request to be conditional.
*/
PRECONDITION_REQUIRED: 428,
/**
* The user has sent too many requests in a given amount of time.
*/
TOO_MANY_REQUESTS: 429,
/**
* The server is unwilling to process the request because either
* an individual header field or all the header fields collectively,
* are too large.
*/
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
/**
* A server operator has received a legal demand to deny access to a
* resource or to a set of resources that includes the requested resource.
*/
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
// 5xx Server Error
/**
* HTTP status code indicating that the server encountered an unexpected
* condition that prevented it from fulfilling the request.
*/
INTERNAL_SERVER_ERROR: 500,
/**
* HTTP status code indicating that the server does not support the
* functionality required to fulfill the request.
*/
NOT_IMPLEMENTED: 501,
/**
* HTTP status code indicating that the server, while acting as a
* gateway or proxy, received an invalid response from the upstream server.
*/
BAD_GATEWAY: 502,
/**
* HTTP status code indicating that the server is currently unable
* to handle the request due to a temporary overload or maintenance
* of the server.
*/
SERVICE_UNAVAILABLE: 503,
/**
* HTTP status code indicating that the server, while acting as a gateway
* or proxy, did not receive a timely response from the upstream server.
*/
GATEWAY_TIMEOUT: 504,
/**
* HTTP status code indicating that the server does not support, or refuses
* to support, the HTTP protocol version that was used in the request message.
*/
HTTP_VERSION_NOT_SUPPORTED: 505,
/**
* HTTP status code indicating that the server has an internal configuration
* error: the chosen variant resource is configured to engage in transparent
* content negotiation itself, and is therefore not a proper endpoint in the
* negotiation process.
*/
VARIANT_ALSO_NEGOTIATES: 506,
/**
* HTTP status code indicating that the server is unable to store the
* representation needed to complete the request.
*/
INSUFFICIENT_STORAGE: 507,
/**
* HTTP status code indicating that the server detected an infinite loop
* while processing the request.
*/
LOOP_DETECTED: 508,
/**
* The 510 status code indicates that the client needs to authenticate to
* gain network access.
*/
NOT_EXTENDED: 510,
/**
* HTTP status code indicating that the client needs to authenticate
* to gain network access.
*/
NETWORK_AUTHENTICATION_REQUIRED: 511
};
module.exports = {
API_STATUS_CODES
}
Created
March 21, 2023 04:13
-
-
Save rifayetuxbd/5af5ec7cb4f1d2c3c6ce8a3fcdbd8bc0 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment