sheik-mostafizur/http-status-kit

Repository files navigation

A simple utility kit for handling HTTP status codes and messages, providing a consistent and convenient way to manage common HTTP status scenarios.

http-status-kit is a lightweight utility kit that provides a set of HTTP status codes and messages.We are focus this messages base on users experience or UX. It simplifies the process of errors and responses in your Node.js applications.

You can install http-status-kit using npm:

npm install http-status-kit

or using yarn:

yarn add http-status-kit

or using pnpm:

pnpm add http-status-kit
import { statusCodes, statusMessages } from "http-status-kit";

// response back code with message
response.status(statusCodes.OK).send(statusMessages.OK);

response.status(statusCodes.OK).send(`PROFILE: ${statusMessages.OK}`);
response.status(statusCodes.OK).send(`PRODUCTS: ${statusMessages.OK}`);
response.status(statusCodes.OK).send(`ITEMS: ${statusMessages.OK}`);
CodeNameMessage
100CONTINUEContinue sending data.
101SWITCHING_PROTOCOLSSwitching protocols as requested.
102PROCESSINGThe server has received the request and is still processing it.
103EARLY_HINTSThe server is returning some headers before the final response.
200OKSuccess! Your request has been completed.
201CREATEDSuccess! New resource created.
202ACCEPTEDRequest received! We're working on it.
203NON_AUTHORITATIVE_INFORMATIONThe request was successful but the information may be from a third party.
204NO_CONTENTSuccess! No additional content available.
205RESET_CONTENTThe request was successful, please reset the document view.
206PARTIAL_CONTENTThe server is delivering only part of the resource due to a range header sent by the client.
207MULTI_STATUSThe message body contains multiple status codes for separate operations (WebDAV).
208ALREADY_REPORTEDThe members of a DAV binding have already been enumerated (WebDAV).
226IM_USEDServer fulfilled the request with changes applied.
300MULTIPLE_CHOICESMultiple options available. Please choose one.
301MOVED_PERMANENTLYThe requested resource has been permanently moved to a new URL.
302FOUNDResource temporarily moved. Please wait while we redirect you...
303SEE_OTHERThe answer is accessible via a different URI with a GET request.
304NOT_MODIFIEDThe resource is unchanged since the last request.
305USE_PROXYThe requested resource must be accessed through the proxy.
307TEMPORARY_REDIRECTThe request should be repeated with another URI temporarily.
308PERMANENT_REDIRECTThe request and future requests should be repeated with another URI permanently.
400BAD_REQUESTRequest not understood due to syntax error.
401UNAUTHORIZEDYou must authenticate to proceed.
402PAYMENT_REQUIREDPayment is required to access the requested resource.
403FORBIDDENYou don't have permission to view this.
404NOT_FOUNDRequested resource unavailable.
405METHOD_NOT_ALLOWEDThe method specified in the request is not allowed for the resource.
406NOT_ACCEPTABLERequested resource can't provide acceptable content.
407PROXY_AUTHENTICATION_REQUIREDThe client must authenticate itself with the proxy.
408REQUEST_TIMEOUTThe server timed out waiting for the request.
409CONFLICTThe request conflicts with the current state of the resource.
410GONEThe requested resource is no longer available and will not be available again.
411LENGTH_REQUIREDThe server requires the Content-Length header to be sent with the request.
412PRECONDITION_FAILEDOne or more conditions given in the request header fields were evaluated as false.
413PAYLOAD_TOO_LARGEThe request is larger than the server is willing or able to process.
414URI_TOO_LONGThe URI provided was too long for the server to process.
415UNSUPPORTED_MEDIA_TYPEThe media format of the requested data is not supported by the server.
416RANGE_NOT_SATISFIABLEThe range specified by the Range header field in the request can't be fulfilled.
417EXPECTATION_FAILEDThe expectation given in the request header could not be met by the server.
418IM_A_TEAPOTThe server refuses the attempt to brew coffee with a teapot.
421MISDIRECTED_REQUESTThe request was directed at a server that is not able to produce a response.
422UNPROCESSABLE_ENTITYThe request was well-formed but was unable to be followed due to semantic errors.
423LOCKEDThe resource that is being accessed is locked.
424FAILED_DEPENDENCYThe request failed due to failure of a previous request.
425TOO_EARLYThe server is unwilling to risk processing a request that might be replayed.
426UPGRADE_REQUIREDThe client should switch to a different protocol.
428PRECONDITION_REQUIREDThe origin server requires the request to be conditional.
429TOO_MANY_REQUESTSYou've sent too many requests.
431REQUEST_HEADER_FIELDS_TOO_LARGEThe server is unwilling to process the request because its header fields are too large.
451UNAVAILABLE_FOR_LEGAL_REASONSThe server is denying access to the resource as a consequence of a legal demand.
500INTERNAL_SERVER_ERRORAn unexpected error occurred.
501NOT_IMPLEMENTEDThe server does not support the functionality required to fulfill the request.
502BAD_GATEWAYThe server, while acting as a gateway or proxy, received an invalid response from the upstream server.
503SERVICE_UNAVAILABLEServer not ready, try again later.
504GATEWAY_TIMEOUTThe server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.
505HTTP_VERSION_NOT_SUPPORTEDThe server does not support the HTTP protocol version that was used in the request.
506VARIANT_ALSO_NEGOTIATESThe server has an internal configuration error and needs to negotiate a different variant.
507INSUFFICIENT_STORAGEThe server is unable to store the representation needed to complete the request.
508LOOP_DETECTEDThe server detected an infinite loop while processing the request (WebDAV).
510NOT_EXTENDEDFurther extensions to the request are required for the server to fulfill it.

If you'd like to contribute to http-status-kit, please fork the repository and submit a pull request. You can also report issues or suggest new features on the issue tracker.

http-status-kit is licensed under the ISC license.

About

http code and common message

Topics

Resources

License

Stars

Watchers

Forks