@curveball/http-errors
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -0,3 +1,13 @@ | ||
Changelog | ||
========= | ||
0.4.0 (2021-02-18) | ||
------------------- | ||
* Update everything to latest curveball standards. | ||
* Publish on github packages | ||
0.3.0 (2018-10-01) | ||
================= | ||
----------------- | ||
@@ -10,3 +20,3 @@ * Mass-renamed httpCode to the more common httpStatus. | ||
0.2.2 (2018-09-14) | ||
================== | ||
------------------ | ||
@@ -18,3 +28,3 @@ * Added `isHttpProblem()` helper function. | ||
0.2.1 (2018-09-14) | ||
================== | ||
------------------ | ||
@@ -26,3 +36,3 @@ * The `allow` parameter from `MethodNotAllowed` is now optional. | ||
0.2.0 (2018-09-12) | ||
================== | ||
------------------ | ||
@@ -35,3 +45,3 @@ * Added `Unauthorized`, `PaymentRequired`, `Forbidden`. | ||
0.1.0 (2018-09-11) | ||
================== | ||
------------------ | ||
@@ -46,4 +56,4 @@ * Dropped `ClientError` and `ServerError` interfaces, they aren't useful in | ||
0.0.1 (2018-09-11) | ||
================== | ||
------------------ | ||
* First version with just a few errors to test the ergonomics of this package. |
@@ -41,3 +41,3 @@ export interface HttpError extends Error { | ||
title: string; | ||
wwwAuthenticate: AuthenticateChallenge; | ||
wwwAuthenticate?: AuthenticateChallenge; | ||
constructor(detail?: string | null, wwwAuthenticate?: AuthenticateChallenge); | ||
@@ -78,3 +78,3 @@ } | ||
title: string; | ||
allow: string[]; | ||
allow?: string[]; | ||
constructor(detail?: string | null, allow?: string[]); | ||
@@ -103,3 +103,3 @@ } | ||
title: string; | ||
proxyAuthenticate: AuthenticateChallenge; | ||
proxyAuthenticate?: AuthenticateChallenge; | ||
constructor(detail?: string | null, proxyAuthenticate?: AuthenticateChallenge); | ||
@@ -106,0 +106,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NetworkAuthenticationRequired = exports.NotExtended = exports.LoopDetected = exports.UnsufficientStorage = exports.VariantAlsoNegotiates = exports.HttpVersionNotSupported = exports.GatewayTimeout = exports.ServiceUnavailable = exports.BadGateway = exports.NotImplemented = exports.InternalServerError = exports.UnavailableForLegalReasons = exports.RequestHeaderFieldsTooLarge = exports.TooManyRequests = exports.PreconditionRequired = exports.UpgradeRequired = exports.TooEarly = exports.FailedDependency = exports.Locked = exports.UnprocessableEntity = exports.MisdirectedRequest = exports.ExpectationFailed = exports.RangeNotSatisfiable = exports.UnsupportedMediaType = exports.UriTooLong = exports.PayloadTooLarge = exports.PreconditionFailed = exports.LengthRequired = exports.Gone = exports.Conflict = exports.RequestTimeout = exports.ProxyAuthenticationRequired = exports.NotAcceptable = exports.MethodNotAllowed = exports.NotFound = exports.Forbidden = exports.PaymentRequired = exports.Unauthorized = exports.BadRequest = exports.isServerError = exports.isClientError = exports.HttpErrorBase = exports.isHttpProblem = exports.isHttpError = void 0; | ||
function isHttpError(e) { | ||
@@ -13,3 +14,3 @@ return Number.isInteger(e.httpStatus); | ||
constructor(detail = null) { | ||
super(detail); | ||
super(detail || 'HTTP error'); | ||
this.type = null; | ||
@@ -21,3 +22,2 @@ this.httpStatus = 500; | ||
this.detail = detail; | ||
this.message = detail; | ||
} | ||
@@ -24,0 +24,0 @@ } |
{ | ||
"name": "@curveball/http-errors", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A standard package for HTTP exceptions", | ||
@@ -13,3 +13,3 @@ "main": "dist/index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/curveballjs/http-errors.git" | ||
"url": "git+https://github.com/curveball/http-errors.git" | ||
}, | ||
@@ -32,17 +32,19 @@ "files": [ | ||
"bugs": { | ||
"url": "https://github.com/curveballjs/http-errors/issues" | ||
"url": "https://github.com/curveball/http-errors/issues" | ||
}, | ||
"homepage": "https://github.com/curveballjs/http-errors#readme", | ||
"homepage": "https://github.com/curveball/http-errors#readme", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.4", | ||
"@types/mocha": "^5.2.3", | ||
"@types/node": "^10.3.6", | ||
"@types/sinon": "^5.0.1", | ||
"chai": "^4.1.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^12.0.2", | ||
"sinon": "^6.0.1", | ||
"ts-node": "^7.0.0", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.9.2" | ||
"@types/chai": "^4.2.12", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node": "^10.17.35", | ||
"@types/sinon": "^9.0.7", | ||
"@typescript-eslint/eslint-plugin": "^4.3.0", | ||
"@typescript-eslint/parser": "^4.3.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.10.0", | ||
"mocha": "^8.1.3", | ||
"nyc": "^15.1.0", | ||
"sinon": "^9.1.0", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.3" | ||
}, | ||
@@ -54,3 +56,12 @@ "types": "dist/", | ||
] | ||
}, | ||
"mocha": { | ||
"require": "ts-node/register", | ||
"recursive": true, | ||
"extension": [ | ||
"ts", | ||
"js", | ||
"tsx" | ||
] | ||
} | ||
} |
HTTP Errors | ||
=========== | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/curveball/http-errors.svg)](https://greenkeeper.io/) | ||
This package contains a list of standard HTTP exceptions for Typescript. They | ||
@@ -91,7 +93,7 @@ can be emitted from a Node.js web application written in for example [Koa][2] | ||
Lastly, a few HTTP errors require or suggest including extra HTTP headers with | ||
more information about headers. For example, the `405 Method Not Allowed` | ||
header should contain an `Allow` header, and the `503 Service Unavailable` | ||
Lastly, a few HTTP responses require or suggest including extra HTTP headers with | ||
more information about the error. For example, the `405 Method Not Allowed` | ||
response should include an `Allow` header, and the `503 Service Unavailable` | ||
should have a `Retry-After` header. The built-in error classes include support | ||
for these: | ||
these: | ||
@@ -228,4 +230,4 @@ ```typescript | ||
[1]: https://github.com/curveballjs/ | ||
[1]: https://github.com/curveball/ | ||
[2]: http://koajs.com/ | ||
[3]: https://tools.ietf.org/html/rfc7807 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40385
8
868
232
13