Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-status-codes

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-status-codes - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0-beta.4

build/index.d.ts

354

build/index.js

@@ -728,3 +728,3 @@ module.exports =

})(ReasonPhrases || (ReasonPhrases = {}));
const statusCodeToReasonPhrase = {
var statusCodeToReasonPhrase = {
"202": "Accepted",

@@ -785,3 +785,3 @@ "502": "Bad Gateway",

};
const reasonPhraseToStatusCode = {
var reasonPhraseToStatusCode = {
"Accepted": 202,

@@ -846,5 +846,59 @@ "Bad Gateway": 502,

/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStatusCode", function() { return getStatusCode; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStatusText", function() { return getStatusText; });
/* concated harmony reexport */ __webpack_require__.d(__webpack_exports__, "StatusCodes", function() { return StatusCodes; });
/* concated harmony reexport */ __webpack_require__.d(__webpack_exports__, "ReasonPhrases", function() { return ReasonPhrases; });
/* harmony export export */ __webpack_require__.d(__webpack_exports__, "default", function() { return build_tmp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ACCEPTED", function() { return ACCEPTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BAD_GATEWAY", function() { return BAD_GATEWAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BAD_REQUEST", function() { return BAD_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONFLICT", function() { return CONFLICT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTINUE", function() { return CONTINUE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CREATED", function() { return CREATED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EXPECTATION_FAILED", function() { return EXPECTATION_FAILED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FAILED_DEPENDENCY", function() { return FAILED_DEPENDENCY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FORBIDDEN", function() { return FORBIDDEN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GATEWAY_TIMEOUT", function() { return GATEWAY_TIMEOUT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GONE", function() { return GONE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HTTP_VERSION_NOT_SUPPORTED", function() { return HTTP_VERSION_NOT_SUPPORTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IM_A_TEAPOT", function() { return IM_A_TEAPOT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "INSUFFICIENT_SPACE_ON_RESOURCE", function() { return INSUFFICIENT_SPACE_ON_RESOURCE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "INSUFFICIENT_STORAGE", function() { return INSUFFICIENT_STORAGE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "INTERNAL_SERVER_ERROR", function() { return INTERNAL_SERVER_ERROR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LENGTH_REQUIRED", function() { return LENGTH_REQUIRED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LOCKED", function() { return LOCKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "METHOD_FAILURE", function() { return METHOD_FAILURE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "METHOD_NOT_ALLOWED", function() { return METHOD_NOT_ALLOWED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MOVED_PERMANENTLY", function() { return MOVED_PERMANENTLY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MOVED_TEMPORARILY", function() { return MOVED_TEMPORARILY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MULTI_STATUS", function() { return MULTI_STATUS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MULTIPLE_CHOICES", function() { return MULTIPLE_CHOICES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NETWORK_AUTHENTICATION_REQUIRED", function() { return NETWORK_AUTHENTICATION_REQUIRED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NO_CONTENT", function() { return NO_CONTENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_AUTHORITATIVE_INFORMATION", function() { return NON_AUTHORITATIVE_INFORMATION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NOT_ACCEPTABLE", function() { return NOT_ACCEPTABLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NOT_FOUND", function() { return NOT_FOUND; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NOT_IMPLEMENTED", function() { return NOT_IMPLEMENTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NOT_MODIFIED", function() { return NOT_MODIFIED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OK", function() { return OK; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PARTIAL_CONTENT", function() { return PARTIAL_CONTENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PAYMENT_REQUIRED", function() { return PAYMENT_REQUIRED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PERMANENT_REDIRECT", function() { return PERMANENT_REDIRECT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PRECONDITION_FAILED", function() { return PRECONDITION_FAILED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PRECONDITION_REQUIRED", function() { return PRECONDITION_REQUIRED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PROCESSING", function() { return PROCESSING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PROXY_AUTHENTICATION_REQUIRED", function() { return PROXY_AUTHENTICATION_REQUIRED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REQUEST_HEADER_FIELDS_TOO_LARGE", function() { return REQUEST_HEADER_FIELDS_TOO_LARGE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REQUEST_TIMEOUT", function() { return REQUEST_TIMEOUT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REQUEST_TOO_LONG", function() { return REQUEST_TOO_LONG; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REQUEST_URI_TOO_LONG", function() { return REQUEST_URI_TOO_LONG; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REQUESTED_RANGE_NOT_SATISFIABLE", function() { return REQUESTED_RANGE_NOT_SATISFIABLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RESET_CONTENT", function() { return RESET_CONTENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEE_OTHER", function() { return SEE_OTHER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SERVICE_UNAVAILABLE", function() { return SERVICE_UNAVAILABLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SWITCHING_PROTOCOLS", function() { return SWITCHING_PROTOCOLS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TEMPORARY_REDIRECT", function() { return TEMPORARY_REDIRECT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TOO_MANY_REQUESTS", function() { return TOO_MANY_REQUESTS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UNAUTHORIZED", function() { return UNAUTHORIZED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UNPROCESSABLE_ENTITY", function() { return UNPROCESSABLE_ENTITY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UNSUPPORTED_MEDIA_TYPE", function() { return UNSUPPORTED_MEDIA_TYPE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "USE_PROXY", function() { return USE_PROXY; });

@@ -871,13 +925,287 @@ /**

}
/**
* @deprecated
*
* Returns the reason phrase for the given status code.
* If the given status code does not exist, undefined is returned.
*
* Deprecated in favor of getReasonPhrase
*
* @param {number|string} statusCode The HTTP status code
* @returns {string|undefined} The associated reason phrase (e.g. "Bad Request", "OK")
* */
var getStatusText = getReasonPhrase;
// Default exports are deprecated, but maintained for v1 compatability
const defaultExports = {};
// Exporting constant to code directly to maintain compatability with v1
Object.entries(StatusCodes).forEach(([key, value]) => {
defaultExports[key] = value;
});
// Exporting getStatusText and getStatusCode directly to maintain compatability with v1
defaultExports.getStatusText = getReasonPhrase;
defaultExports.getStatusCode = getStatusCode;
/* harmony default export */ var build_tmp = (defaultExports);
// Exporting constants directly to maintain compatability with v1
// These are deprecated. Please don't add any new codes here.
/**
* @deprecated Please use StatusCodes.ACCEPTED
*
* */
var ACCEPTED = 202;
/**
* @deprecated Please use StatusCodes.BAD_GATEWAY
*
* */
var BAD_GATEWAY = 502;
/**
* @deprecated Please use StatusCodes.BAD_REQUEST
*
* */
var BAD_REQUEST = 400;
/**
* @deprecated Please use StatusCodes.CONFLICT
*
* */
var CONFLICT = 409;
/**
* @deprecated Please use StatusCodes.CONTINUE
*
* */
var CONTINUE = 100;
/**
* @deprecated Please use StatusCodes.CREATED
*
* */
var CREATED = 201;
/**
* @deprecated Please use StatusCodes.EXPECTATION_FAILED
*
* */
var EXPECTATION_FAILED = 417;
/**
* @deprecated Please use StatusCodes.FAILED_DEPENDENCY
*
* */
var FAILED_DEPENDENCY = 424;
/**
* @deprecated Please use StatusCodes.FORBIDDEN
*
* */
var FORBIDDEN = 403;
/**
* @deprecated Please use StatusCodes.GATEWAY_TIMEOUT
*
* */
var GATEWAY_TIMEOUT = 504;
/**
* @deprecated Please use StatusCodes.GONE
*
* */
var GONE = 410;
/**
* @deprecated Please use StatusCodes.HTTP_VERSION_NOT_SUPPORTED
*
* */
var HTTP_VERSION_NOT_SUPPORTED = 505;
/**
* @deprecated Please use StatusCodes.IM_A_TEAPOT
*
* */
var IM_A_TEAPOT = 418;
/**
* @deprecated Please use StatusCodes.INSUFFICIENT_SPACE_ON_RESOURCE
*
* */
var INSUFFICIENT_SPACE_ON_RESOURCE = 419;
/**
* @deprecated Please use StatusCodes.INSUFFICIENT_STORAGE
*
* */
var INSUFFICIENT_STORAGE = 507;
/**
* @deprecated Please use StatusCodes.INTERNAL_SERVER_ERROR
*
* */
var INTERNAL_SERVER_ERROR = 500;
/**
* @deprecated Please use StatusCodes.LENGTH_REQUIRED
*
* */
var LENGTH_REQUIRED = 411;
/**
* @deprecated Please use StatusCodes.LOCKED
*
* */
var LOCKED = 423;
/**
* @deprecated Please use StatusCodes.METHOD_FAILURE
*
* */
var METHOD_FAILURE = 420;
/**
* @deprecated Please use StatusCodes.METHOD_NOT_ALLOWED
*
* */
var METHOD_NOT_ALLOWED = 405;
/**
* @deprecated Please use StatusCodes.MOVED_PERMANENTLY
*
* */
var MOVED_PERMANENTLY = 301;
/**
* @deprecated Please use StatusCodes.MOVED_TEMPORARILY
*
* */
var MOVED_TEMPORARILY = 302;
/**
* @deprecated Please use StatusCodes.MULTI_STATUS
*
* */
var MULTI_STATUS = 207;
/**
* @deprecated Please use StatusCodes.MULTIPLE_CHOICES
*
* */
var MULTIPLE_CHOICES = 300;
/**
* @deprecated Please use StatusCodes.NETWORK_AUTHENTICATION_REQUIRED
*
* */
var NETWORK_AUTHENTICATION_REQUIRED = 511;
/**
* @deprecated Please use StatusCodes.NO_CONTENT
*
* */
var NO_CONTENT = 204;
/**
* @deprecated Please use StatusCodes.NON_AUTHORITATIVE_INFORMATION
*
* */
var NON_AUTHORITATIVE_INFORMATION = 203;
/**
* @deprecated Please use StatusCodes.NOT_ACCEPTABLE
*
* */
var NOT_ACCEPTABLE = 406;
/**
* @deprecated Please use StatusCodes.NOT_FOUND
*
* */
var NOT_FOUND = 404;
/**
* @deprecated Please use StatusCodes.NOT_IMPLEMENTED
*
* */
var NOT_IMPLEMENTED = 501;
/**
* @deprecated Please use StatusCodes.NOT_MODIFIED
*
* */
var NOT_MODIFIED = 304;
/**
* @deprecated Please use StatusCodes.OK
*
* */
var OK = 200;
/**
* @deprecated Please use StatusCodes.PARTIAL_CONTENT
*
* */
var PARTIAL_CONTENT = 206;
/**
* @deprecated Please use StatusCodes.PAYMENT_REQUIRED
*
* */
var PAYMENT_REQUIRED = 402;
/**
* @deprecated Please use StatusCodes.PERMANENT_REDIRECT
*
* */
var PERMANENT_REDIRECT = 308;
/**
* @deprecated Please use StatusCodes.PRECONDITION_FAILED
*
* */
var PRECONDITION_FAILED = 412;
/**
* @deprecated Please use StatusCodes.PRECONDITION_REQUIRED
*
* */
var PRECONDITION_REQUIRED = 428;
/**
* @deprecated Please use StatusCodes.PROCESSING
*
* */
var PROCESSING = 102;
/**
* @deprecated Please use StatusCodes.PROXY_AUTHENTICATION_REQUIRED
*
* */
var PROXY_AUTHENTICATION_REQUIRED = 407;
/**
* @deprecated Please use StatusCodes.REQUEST_HEADER_FIELDS_TOO_LARGE
*
* */
var REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
/**
* @deprecated Please use StatusCodes.REQUEST_TIMEOUT
*
* */
var REQUEST_TIMEOUT = 408;
/**
* @deprecated Please use StatusCodes.REQUEST_TOO_LONG
*
* */
var REQUEST_TOO_LONG = 413;
/**
* @deprecated Please use StatusCodes.REQUEST_URI_TOO_LONG
*
* */
var REQUEST_URI_TOO_LONG = 414;
/**
* @deprecated Please use StatusCodes.REQUESTED_RANGE_NOT_SATISFIABLE
*
* */
var REQUESTED_RANGE_NOT_SATISFIABLE = 416;
/**
* @deprecated Please use StatusCodes.RESET_CONTENT
*
* */
var RESET_CONTENT = 205;
/**
* @deprecated Please use StatusCodes.SEE_OTHER
*
* */
var SEE_OTHER = 303;
/**
* @deprecated Please use StatusCodes.SERVICE_UNAVAILABLE
*
* */
var SERVICE_UNAVAILABLE = 503;
/**
* @deprecated Please use StatusCodes.SWITCHING_PROTOCOLS
*
* */
var SWITCHING_PROTOCOLS = 101;
/**
* @deprecated Please use StatusCodes.TEMPORARY_REDIRECT
*
* */
var TEMPORARY_REDIRECT = 307;
/**
* @deprecated Please use StatusCodes.TOO_MANY_REQUESTS
*
* */
var TOO_MANY_REQUESTS = 429;
/**
* @deprecated Please use StatusCodes.UNAUTHORIZED
*
* */
var UNAUTHORIZED = 401;
/**
* @deprecated Please use StatusCodes.UNPROCESSABLE_ENTITY
*
* */
var UNPROCESSABLE_ENTITY = 422;
/**
* @deprecated Please use StatusCodes.UNSUPPORTED_MEDIA_TYPE
*
* */
var UNSUPPORTED_MEDIA_TYPE = 415;
/**
* @deprecated Please use StatusCodes.USE_PROXY
*
* */
var USE_PROXY = 305;

@@ -884,0 +1212,0 @@

7

package.json
{
"name": "http-status-codes",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"description": "Constants enumerating the HTTP status codes. Based on the Java Apache HttpStatus API.",
"scripts": {
"update-codes": "ts-node --project ./scripts/tsconfig.json ./scripts/update-codes",
"build-ts": "tsc --project tsconfig-build.json",
"build-concat": "ncc build ./build-tmp/index.js -o ./build",
"build-cleanup": "rm -rf ./build-tmp",
"build": "npm run build-ts && npm run build-concat && npm run build-cleanup",
"build": "./scripts/build.sh",
"lint": "eslint .",

@@ -12,0 +9,0 @@ "test": "jest ./src"

@@ -15,5 +15,5 @@ # http-status-codes

## Usage (express 4.x)
## ES6 Modules Usage (express 4.x)
```javascript
```typescript
import { StatusCodes, ReasonPhrases, getReasonPhrase, getStatusCode } from 'http-status-codes';

@@ -38,2 +38,24 @@

## CommonJS (Node) Usage (express 4.x)
```javascript
import HttpStatusCodes from 'http-status-codes';
response
.status(HttpStatusCodes.StatusCodes.OK)
.send(HttpStatusCodes.ReasonPhrases.OK);
response
.status(HttpStatusCodes.StatusCodes.INTERNAL_SERVER_ERROR)
.send({
error: HttpStatusCodes.getReasonPhrase(HttpStatusCodes.StatusCodes.INTERNAL_SERVER_ERROR)
});
response
.status(HttpStatusCodes.getStatusCode('Internal Server Error'))
.send({
error: 'Internal Server Error'
});
```
## Codes

@@ -100,38 +122,16 @@

v2 is backwards compatible with v1, but if you are migrating from http-status-codes v1 to v2, there are a couple of changes that are recommended.
http-status-codes v2 is mostly backwards compatible with v1, there is a single breaking change and two recommended changes.
### getStatusText renamed getReasonPhrase
### Breaking Change 'Server Error'
To fix this, simply rename `getStatusText()` to `getReasonPhrase()`. The function is otherwise the same as it was before.
The reason phrase for the status code 500 has been changed from 'Server Error' to 'Internal Server Error'. This is the correct phrase according to RFC7231. If you have code that relies on the result of `getStatusText(500)` or `getReasonPhrase('Server Error')`, then this could affect you.
**bad** ❌
### Non-breaking change getStatusText renamed getReasonPhrase
```
getStatusText(200);
```
The function getStatusText has been renamed to getReasonPhrase. The old function is still available but may be deprecated in a future version. To fix this, simply rename `getStatusText()` to `getReasonPhrase()`. The function is otherwise the same as it was before.
**good** ✅
### Non-breaking change StatusCodes
```
getReasonPhrase(200);
```
In http-status-codes v1, Status Codes were exported directly from the top-level module. i.e. `HttpStatus.OK`. In v2 all Status Codes live under an object called `HttpStatus.StatusCodes`. We made this change to cater to TypeScript users who prefer a dedicated value with an enum type. The previous values are still exported, but we won't continue to update them. Please migrate if you're using the old-style imports.
### No wildcard imports
We're moving away from wildcard imports in favor of selective imports.
**bad** ❌
```typescript
import * as HttpStatus from 'http-status-codes';
```
**good** ✅
```typescript
import { StatusCodes } from 'http-status-codes';
```
These changes are __optional__ now, but may be required in a future major version so please consider making them now.
## Proposing a new status code

@@ -138,0 +138,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc