semantic-response
v1.0.4
Published
Simple Node.js package that aims to create standardized responses for HTTP applications.
Readme
Semantic Response
Simple Node.js package that aims to create standardized responses for HTTP applications.
Installation
npm install semantic-responseUsage
const { HttpResponse } = require("semantic-response");
// Example: Creating a success response
const successResponse = HttpResponse.ok({ name: "John Doe", email: "[email protected]" });
console.log(successResponse);
// Example: Creating an error response
const errorResponse = HttpResponse.badRequest({ invalidFields: ["name", "email"] }, "The request you sent is invalid");
console.log(errorResponse);
// Example: Creating another error response
const anotherErrorResponse = HttpResponse.internalServerError(errorDataObj, "Something went wrong");
console.log(anotherErrorResponse);Available Functions
continueswitchingProtocolsprocessingearlyHintsokcreatedacceptednonAuthoritativeInformationnoContentresetContentpartialContentmultiStatusalreadyReportedimUsedmultipleChoicesmovedPermanentlyfoundseeOthernotModifieduseProxyswitchProxytemporaryRedirectpermanentRedirectbadRequestunauthorizedpaymentRequiredforbiddennotFoundmethodNotAllowednotAcceptableproxyAuthenticationRequiredrequestTimeoutconflictgonelengthRequiredpreconditionFailedpayloadTooLargeuriTooLongunsupportedMediaTyperangeNotSatisfiableexpectationFailediAmATeapotmisdirectedRequestunprocessableEntitylockedfailedDependencytooEarlyupgradeRequiredpreconditionRequiredtooManyRequestsrequestHeaderFieldsTooLargeunavailableForLegalReasonsinternalServerErrornotImplementedbadGatewayserviceUnavailablegatewayTimeouthttpVersionNotSupportedvariantAlsoNegotiatesinsufficientStorageloopDetectednotExtendednetworkAuthenticationRequired
License
This project is licensed under the MIT License - see the LICENSE file for details.
