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

@curveball/http-errors

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@curveball/http-errors - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

changelog.md

@@ -0,1 +1,9 @@

0.2.0 (2018-09-12)
==================
* Added `Unauthorized`, `PaymentRequired`, `Forbidden`.
* Added support for `WWW-Authenticate` header for 401 responses and `Allow`
for 405 responses.
0.1.0 (2018-09-11)

@@ -2,0 +10,0 @@ ==================

@@ -21,2 +21,37 @@ export interface HttpError extends Error {

}
declare type WwwAuthenticate = string | string[];
/**
* Emits a 401 Unauthorized.
*
* This response must come with a WWW-Authenticate header. This challenge can
* optionally be provided via the constructor.
*
* examples:
* new Unauthorized('Login failed', 'Basic');
* new Unauthorized('Login failed', 'Basic; realm="secret area"');
* new Unauthorized('Login failed', ['Basic; realm="secret area', 'Bearer']);
*/
export declare class Unauthorized extends HttpErrorBase {
httpCode: number;
title: string;
wwwAuthenticate: WwwAuthenticate;
constructor(detail?: string | null, wwwAuthenticate?: WwwAuthenticate);
}
/**
* Emits 402 Payment Required
*/
export declare class PaymentRequired extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 403 Forbidden
*/
export declare class Forbidden extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 404 Not Found
*/
export declare class NotFound extends HttpErrorBase {

@@ -26,6 +61,20 @@ httpCode: number;

}
/**
* Emits 405 Method Not Allowed.
*
* The 405 Method Not Allowed HTTP response requires an Allow header.
* You can optionally use the second argument to provide this.
*
* Example:
* new MethodNotAllowed('This resource is read-only', ['GET', 'HEAD', 'OPTIONS']);
*/
export declare class MethodNotAllowed extends HttpErrorBase {
httpCode: number;
title: string;
allow: string[];
constructor(detail: string | null, allow: string[]);
}
/**
* Emits 500 Internal Server Error
*/
export declare class InternalServerError extends HttpErrorBase {

@@ -35,2 +84,5 @@ httpCode: number;

}
/**
* Emits 501 Not Implemented
*/
export declare class NotImplemented extends HttpErrorBase {

@@ -40,1 +92,2 @@ httpCode: number;

}
export {};

65

dist/index.js

@@ -36,2 +36,47 @@ "use strict";

exports.BadRequest = BadRequest;
/**
* Emits a 401 Unauthorized.
*
* This response must come with a WWW-Authenticate header. This challenge can
* optionally be provided via the constructor.
*
* examples:
* new Unauthorized('Login failed', 'Basic');
* new Unauthorized('Login failed', 'Basic; realm="secret area"');
* new Unauthorized('Login failed', ['Basic; realm="secret area', 'Bearer']);
*/
class Unauthorized extends HttpErrorBase {
constructor(detail = null, wwwAuthenticate) {
super(detail);
this.httpCode = 401;
this.title = 'Unauthorized';
this.wwwAuthenticate = wwwAuthenticate;
}
}
exports.Unauthorized = Unauthorized;
/**
* Emits 402 Payment Required
*/
class PaymentRequired extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 402;
this.title = 'Payment Required';
}
}
exports.PaymentRequired = PaymentRequired;
/**
* Emits 403 Forbidden
*/
class Forbidden extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 403;
this.title = 'Forbiddden';
}
}
exports.Forbidden = Forbidden;
/**
* Emits 404 Not Found
*/
class NotFound extends HttpErrorBase {

@@ -45,10 +90,23 @@ constructor() {

exports.NotFound = NotFound;
/**
* Emits 405 Method Not Allowed.
*
* The 405 Method Not Allowed HTTP response requires an Allow header.
* You can optionally use the second argument to provide this.
*
* Example:
* new MethodNotAllowed('This resource is read-only', ['GET', 'HEAD', 'OPTIONS']);
*/
class MethodNotAllowed extends HttpErrorBase {
constructor() {
super(...arguments);
constructor(detail = null, allow) {
super(detail);
this.httpCode = 405;
this.title = 'Method Not Allowed';
this.allow = allow;
}
}
exports.MethodNotAllowed = MethodNotAllowed;
/**
* Emits 500 Internal Server Error
*/
class InternalServerError extends HttpErrorBase {

@@ -62,2 +120,5 @@ constructor() {

exports.InternalServerError = InternalServerError;
/**
* Emits 501 Not Implemented
*/
class NotImplemented extends HttpErrorBase {

@@ -64,0 +125,0 @@ constructor() {

2

package.json
{
"name": "@curveball/http-errors",
"version": "0.1.0",
"version": "0.2.0",
"description": "A standard package for HTTP exceptions",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

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