Skip to content
HTTP status codes as a TypeScript enum.
Branch: master
Clone or download
Pull request Compare This branch is 38 commits behind typeslick:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
__meta__
src
.babelrc.js
.gitignore
.prettierrc.json
CODE_OF_CONDUCT.md
LICENSE
README.md
api-extractor.json
cSpell.json
jest.config.js
package.json
tsconfig.json
tslint.json

README.md

status-code-enum

HTTP status codes as a TypeScript enum.

tslint: Slick code style: Prettier npm semantic-release License

Install

$ npm install status-code-enum

Usage

Node.js / CommonJS:

const { StatusCode } = require('status-code-enum')
res.statusCode = StatusCode.ClientErrorBadRequest

ES6 / TypeScript:

import { StatusCode } from 'status-code-enum'
res.statusCode = StatusCode.ClientErrorBadRequest

All current standard HTTP status codes are available as follows:

Client Error:

  • ClientErrorBadRequest = 400
  • ClientErrorConflict = 409
  • ClientErrorExpectationFailed = 417
  • ClientErrorFailedDependency = 424
  • ClientErrorForbidden = 403
  • ClientErrorGone = 410
  • ClientErrorImATeapot = 418
  • ClientErrorLengthRequired = 411
  • ClientErrorLocked = 423
  • ClientErrorLoginTimeOut = 440
  • ClientErrorMethodNotAllowed = 405
  • ClientErrorMisdirectedRequest = 421
  • ClientErrorNotAcceptable = 406
  • ClientErrorNotFound = 404
  • ClientErrorPayloadTooLarge = 413
  • ClientErrorPaymentRequired = 402
  • ClientErrorPreconditionFailed = 412
  • ClientErrorPreconditionRequired = 428
  • ClientErrorProxyAuthRequired = 407
  • ClientErrorRangeNotSatisfiable = 416
  • ClientErrorRequestHeaderFieldsTooLarge = 431
  • ClientErrorRequestTimeout = 408
  • ClientErrorRetryWith = 449
  • ClientErrorTooManyRequests = 429
  • ClientErrorUnauthorized = 401
  • ClientErrorUnavailableForLegalReasons = 451
  • ClientErrorUnprocessableEntity = 422
  • ClientErrorUnsupportedMediaType = 415
  • ClientErrorUpgradeRequired = 426
  • ClientErrorURITooLong = 414

Info

  • InfoContinue = 100
  • InfoProcessing = 102
  • InfoSwitchingProtocols = 101

Redirect

  • RedirectFound = 302
  • RedirectMovedPermanently = 301
  • RedirectMultipleChoices = 300
  • RedirectNotModified = 304
  • RedirectPermanent = 308
  • RedirectSeeOther = 303
  • RedirectSwitchProxy = 306
  • RedirectTemp = 307
  • RedirectUseProxy = 305

Server Error

  • ServerErrorBadGateway = 502
  • ServerErrorBandwidthLimitExceeded = 509
  • ServerErrorGatewayTimeout = 504
  • ServerErrorHTTPVersionNotSupported = 505
  • ServerErrorInsufficientStorage = 507
  • ServerErrorInternal = 500
  • ServerErrorLoopDetected = 508
  • ServerErrorNetworkAuthRequired = 511
  • ServerErrorNotExtended = 510
  • ServerErrorNotImplemented = 501
  • ServerErrorServiceUnavailable = 503
  • ServerErrorVariantAlsoNegotiates = 506

Success

  • SuccessAccepted = 202
  • SuccessAlreadyReported = 208
  • SuccessCreated = 201
  • SuccessIMUsed = 229
  • SuccessMultiStatus = 207
  • SuccessNoContent = 204
  • SuccessNonAuthoritativeInfo = 203
  • SuccessOK = 200
  • SuccessPartialContent = 206
  • SuccessResetContent = 205

Related

News and Updates

Follow @typeslick on Twitter for the latest updates and new project announcements.

Sponsors

Maintainers

License

MIT

You can’t perform that action at this time.