1.0.3 • Published 4 months ago

semantic-response v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Semantic Response

npm version License: MIT

Simple Node.js package that aims to create standardized responses for HTTP applications.

Installation

npm install semantic-response

Usage

const { HttpResponse } = require("semantic-response");

// Example: Creating a success response
const successResponse = HttpResponse.ok({ name: "John Doe", email: "email@email.com" });
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

  • continue
  • switchingProtocols
  • processing
  • earlyHints

  • ok

  • created
  • accepted
  • nonAuthoritativeInformation
  • noContent
  • resetContent
  • partialContent
  • multiStatus
  • alreadyReported
  • imUsed

  • multipleChoices

  • movedPermanently
  • found
  • seeOther
  • notModified
  • useProxy
  • switchProxy
  • temporaryRedirect
  • permanentRedirect

  • badRequest

  • unauthorized
  • paymentRequired
  • forbidden
  • notFound
  • methodNotAllowed
  • notAcceptable
  • proxyAuthenticationRequired
  • requestTimeout
  • conflict
  • gone
  • lengthRequired
  • preconditionFailed
  • payloadTooLarge
  • uriTooLong
  • unsupportedMediaType
  • rangeNotSatisfiable
  • expectationFailed
  • iAmATeapot
  • misdirectedRequest
  • unprocessableEntity
  • locked
  • failedDependency
  • tooEarly
  • upgradeRequired
  • preconditionRequired
  • tooManyRequests
  • requestHeaderFieldsTooLarge
  • unavailableForLegalReasons

  • internalServerError

  • notImplemented
  • badGateway
  • serviceUnavailable
  • gatewayTimeout
  • httpVersionNotSupported
  • variantAlsoNegotiates
  • insufficientStorage
  • loopDetected
  • notExtended
  • networkAuthenticationRequired

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.2

4 months ago

1.0.3

4 months ago

1.0.1

4 months ago

1.0.0

5 months ago