mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-17 22:44:18 +08:00
* [Boom] Add data type to BoomError #16956 * [Boom] Update TypeScript version to 2.3 in packages that import Boom
This commit is contained in:
committed by
Andy
parent
21a50f928b
commit
7ea548f1fa
@@ -1,45 +1,124 @@
|
||||
|
||||
import Boom = require('boom');
|
||||
|
||||
var bo = Boom.wrap(new Error('test'), 400, 'some message');
|
||||
var a: string = bo.output.headers['some header'];
|
||||
// 4xx and data type
|
||||
|
||||
Boom.create(500, 'Internal server error', { timestamp: Date.now() });
|
||||
const badRequestError = Boom.badRequest('message', {some: 'data'});
|
||||
badRequestError.data.some;
|
||||
|
||||
Boom.badRequest('message', {some: 'data'});
|
||||
Boom.unauthorized('message', <string | string[]> 'scheme', {some: 'data'});
|
||||
Boom.unauthorized(null, <string | string[]> 'scheme', 'data');
|
||||
Boom.paymentRequired('message', {some: 'data'});
|
||||
Boom.forbidden('message', {some: 'data'});
|
||||
Boom.notFound('message', {some: 'data'});
|
||||
Boom.methodNotAllowed('message', {some: 'data'});
|
||||
Boom.notAcceptable('message', {some: 'data'});
|
||||
Boom.proxyAuthRequired('message', {some: 'data'});
|
||||
Boom.clientTimeout('message', {some: 'data'});
|
||||
Boom.conflict('message', {some: 'data'});
|
||||
Boom.resourceGone('message', {some: 'data'});
|
||||
Boom.lengthRequired('message', {some: 'data'});
|
||||
Boom.preconditionFailed('message', {some: 'data'});
|
||||
Boom.entityTooLarge('message', {some: 'data'});
|
||||
Boom.uriTooLong('message', {some: 'data'});
|
||||
Boom.unsupportedMediaType('message', {some: 'data'});
|
||||
Boom.rangeNotSatisfiable('message', {some: 'data'});
|
||||
Boom.expectationFailed('message', {some: 'data'});
|
||||
Boom.teapot('message', {some: 'data'});
|
||||
Boom.badData('message', {some: 'data'});
|
||||
Boom.locked('message', {some: 'data'});
|
||||
Boom.preconditionRequired('message', {some: 'data'});
|
||||
Boom.tooManyRequests('message', {some: 'data'});
|
||||
Boom.illegal('message', {some: 'data'});
|
||||
const unauthorizedError1 = Boom.unauthorized('message', 'scheme', {some: 'attribute'});
|
||||
unauthorizedError1.output.payload.attributes === { some: 'attribute', error: 'message' };
|
||||
unauthorizedError1.output.headers === { 'WWW-Authenticate': 'scheme some="attribute", error="message"' };
|
||||
|
||||
Boom.badImplementation('message', {some: 'data'});
|
||||
Boom.internal('message', {some: 'data'});
|
||||
Boom.notImplemented('message', {some: 'data'});
|
||||
Boom.badGateway('message', {some: 'data'});
|
||||
Boom.serverUnavailable('message', {some: 'data'});
|
||||
Boom.gatewayTimeout('message', {some: 'data'});
|
||||
const unauthorizedError2 = Boom.unauthorized('message', ['scheme']);
|
||||
unauthorizedError2.output.payload.attributes === undefined;
|
||||
unauthorizedError2.output.headers === { 'WWW-Authenticate': 'scheme' };
|
||||
|
||||
Boom.unauthorized() as Error;
|
||||
const unauthorizedError3 = Boom.unauthorized(null, 'scheme', 'attribute');
|
||||
unauthorizedError3.output.payload.attributes === 'attribute';
|
||||
unauthorizedError3.output.headers === { 'WWW-Authenticate': 'scheme attribute' };
|
||||
|
||||
const unauthorizedError4 = Boom.unauthorized(null, 'scheme', {some: 'attribute'});
|
||||
unauthorizedError4.output.payload.attributes === { some: 'attribute' };
|
||||
unauthorizedError4.output.headers === { 'WWW-Authenticate': 'scheme some="attribute"' };
|
||||
|
||||
const paymentRequiredError = Boom.paymentRequired('message', {some: 'data'});
|
||||
paymentRequiredError.data.some;
|
||||
|
||||
const forbiddenError = Boom.forbidden('message', {some: 'data'});
|
||||
forbiddenError.data.some;
|
||||
|
||||
const notFoundError = Boom.notFound('message', {some: 'data'});
|
||||
notFoundError.data.some;
|
||||
|
||||
const methodNotAllowedError = Boom.methodNotAllowed('message', {some: 'data'});
|
||||
methodNotAllowedError.data.some;
|
||||
|
||||
const notAcceptableError = Boom.notAcceptable('message', {some: 'data'});
|
||||
notAcceptableError.data.some;
|
||||
|
||||
const proxyAuthRequiredError = Boom.proxyAuthRequired('message', {some: 'data'});
|
||||
proxyAuthRequiredError.data.some;
|
||||
|
||||
const clientTimeoutError = Boom.clientTimeout('message', {some: 'data'});
|
||||
clientTimeoutError.data.some;
|
||||
|
||||
const conflictError = Boom.conflict('message', {some: 'data'});
|
||||
conflictError.data.some;
|
||||
|
||||
const resourceGoneError = Boom.resourceGone('message', {some: 'data'});
|
||||
resourceGoneError.data.some;
|
||||
|
||||
const lengthRequiredError = Boom.lengthRequired('message', {some: 'data'});
|
||||
lengthRequiredError.data.some;
|
||||
|
||||
const preconditionFailedError = Boom.preconditionFailed('message', {some: 'data'});
|
||||
preconditionFailedError.data.some;
|
||||
|
||||
const entityTooLargeError = Boom.entityTooLarge('message', {some: 'data'});
|
||||
entityTooLargeError.data.some;
|
||||
|
||||
const uriTooLongError = Boom.uriTooLong('message', {some: 'data'});
|
||||
uriTooLongError.data.some;
|
||||
|
||||
const unsupportedMediaTypeError = Boom.unsupportedMediaType('message', {some: 'data'});
|
||||
unsupportedMediaTypeError.data.some;
|
||||
|
||||
const rangeNotSatisfiableError = Boom.rangeNotSatisfiable('message', {some: 'data'});
|
||||
rangeNotSatisfiableError.data.some;
|
||||
|
||||
const expectationFailedError = Boom.expectationFailed('message', {some: 'data'});
|
||||
expectationFailedError.data.some;
|
||||
|
||||
const teapotError = Boom.teapot('message', {some: 'data'});
|
||||
teapotError.data.some;
|
||||
|
||||
const badDataError = Boom.badData('message', {some: 'data'});
|
||||
badDataError.data.some;
|
||||
|
||||
const lockedError = Boom.locked('message', {some: 'data'});
|
||||
lockedError.data.some;
|
||||
|
||||
const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'});
|
||||
preconditionRequiredError.data.some;
|
||||
|
||||
const tooManyRequestsError = Boom.tooManyRequests('message', {some: 'data'});
|
||||
tooManyRequestsError.data.some;
|
||||
|
||||
const illegalError = Boom.illegal('message', {some: 'data'});
|
||||
illegalError.data.some;
|
||||
|
||||
// 5xx and data type
|
||||
|
||||
const badImplementationError = Boom.badImplementation('message', {some: 'data'});
|
||||
badImplementationError.data.some;
|
||||
|
||||
const internalError = Boom.internal('message', {some: 'data'});
|
||||
internalError.data.some;
|
||||
|
||||
const notImplementedError = Boom.notImplemented('message', {some: 'data'});
|
||||
notImplementedError.data.some;
|
||||
|
||||
const badGatewayError = Boom.badGateway('message', {some: 'data'});
|
||||
badGatewayError.data.some;
|
||||
|
||||
const serverUnavailableError = Boom.serverUnavailable('message', {some: 'data'});
|
||||
serverUnavailableError.data.some;
|
||||
|
||||
const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'});
|
||||
gatewayTimeoutError.data.some;
|
||||
|
||||
// wrap and create
|
||||
|
||||
const wrappedError = Boom.wrap(new Error('test'), 400, 'some message');
|
||||
|
||||
const error1 = Boom.create(500, 'Internal server error', { timestamp: Date.now() });
|
||||
error1.data.timestamp;
|
||||
|
||||
// type widden asserting
|
||||
|
||||
const unauthorizedError = Boom.unauthorized() as Error;
|
||||
|
||||
// status code and reformat
|
||||
|
||||
const error = Boom.badRequest('Cannot feed after midnight');
|
||||
error.output.statusCode = 499; // Assign a custom error code
|
||||
|
||||
77
types/boom/index.d.ts
vendored
77
types/boom/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: http://github.com/hapijs/boom
|
||||
// Definitions by: Igor Rogatty <http://github.com/rogatty>, AJP <http://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export = Boom;
|
||||
|
||||
@@ -11,7 +12,7 @@ declare namespace Boom {
|
||||
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
|
||||
* @see {@link https://github.com/hapijs/boom#boom}
|
||||
*/
|
||||
export interface BoomError extends Error {
|
||||
export interface BoomError<Data = null> extends Error {
|
||||
/** isBoom - if true, indicates this is a Boom object instance. */
|
||||
isBoom: boolean;
|
||||
/** isServer - convenience bool indicating status code >= 500. */
|
||||
@@ -24,6 +25,8 @@ declare namespace Boom {
|
||||
reformat: () => string;
|
||||
/** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */
|
||||
isMissing?: boolean;
|
||||
/** https://github.com/hapijs/boom#createstatuscode-message-data */
|
||||
data: Data;
|
||||
}
|
||||
|
||||
export interface Output {
|
||||
@@ -34,6 +37,7 @@ declare namespace Boom {
|
||||
/** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */
|
||||
payload: Payload;
|
||||
}
|
||||
|
||||
export interface Payload {
|
||||
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
|
||||
statusCode: number;
|
||||
@@ -41,6 +45,11 @@ declare namespace Boom {
|
||||
error: string;
|
||||
/** message - the error message derived from error.message. */
|
||||
message: string;
|
||||
/**
|
||||
* "Every key/value pair will be included ... in the response payload under the attributes key."
|
||||
* [see docs](https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes)
|
||||
*/
|
||||
attributes?: any;
|
||||
// Excluded this to aid typing of the other values. See tests for example casting to a custom interface to manipulate the payload
|
||||
// [anyContent: string]: any;
|
||||
}
|
||||
@@ -61,7 +70,7 @@ declare namespace Boom {
|
||||
* @param data additional error data set to error.data property.
|
||||
* @see {@link https://github.com/hapijs/boom#createstatuscode-message-data}
|
||||
*/
|
||||
export function create(statusCode: number, message?: string, data?: any): BoomError;
|
||||
export function create<Data>(statusCode: number, message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
// 4xx
|
||||
/**
|
||||
@@ -70,7 +79,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
|
||||
*/
|
||||
export function badRequest(message?: string, data?: any): BoomError;
|
||||
export function badRequest<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 401 Unauthorized error
|
||||
@@ -81,8 +90,10 @@ declare namespace Boom {
|
||||
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
|
||||
*/
|
||||
export function unauthorized(message?: string, scheme?: string | string[], attributes?: {[index: string]: string}): BoomError;
|
||||
export function unauthorized(message?: null, scheme?: string | string[], attributes?: string): BoomError;
|
||||
export function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): BoomError;
|
||||
export function unauthorized(message?: string, scheme?: string[]): BoomError;
|
||||
export function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): BoomError;
|
||||
export function unauthorized(message?: null, scheme?: string[]): BoomError;
|
||||
|
||||
/**
|
||||
* Returns a 402 Payment Required error
|
||||
@@ -90,7 +101,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
|
||||
*/
|
||||
export function paymentRequired(message?: string, data?: any): BoomError;
|
||||
export function paymentRequired<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 403 Forbidden error
|
||||
@@ -98,7 +109,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
|
||||
*/
|
||||
export function forbidden(message?: string, data?: any): BoomError;
|
||||
export function forbidden<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 404 Not Found error
|
||||
@@ -106,7 +117,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
|
||||
*/
|
||||
export function notFound(message?: string, data?: any): BoomError;
|
||||
export function notFound<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 405 Method Not Allowed error
|
||||
@@ -115,7 +126,7 @@ declare namespace Boom {
|
||||
* @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
|
||||
* @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow}
|
||||
*/
|
||||
export function methodNotAllowed(message?: string, data?: any, allow?: string | string[]): BoomError;
|
||||
export function methodNotAllowed<Data>(message?: string, data?: Data, allow?: string | string[]): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 406 Not Acceptable error
|
||||
@@ -123,7 +134,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
|
||||
*/
|
||||
export function notAcceptable(message?: string, data?: any): BoomError;
|
||||
export function notAcceptable<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 407 Proxy Authentication Required error
|
||||
@@ -131,7 +142,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
|
||||
*/
|
||||
export function proxyAuthRequired(message?: string, data?: any): BoomError;
|
||||
export function proxyAuthRequired<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 408 Request Time-out error
|
||||
@@ -139,7 +150,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
|
||||
*/
|
||||
export function clientTimeout(message?: string, data?: any): BoomError;
|
||||
export function clientTimeout<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 409 Conflict error
|
||||
@@ -147,7 +158,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
|
||||
*/
|
||||
export function conflict(message?: string, data?: any): BoomError;
|
||||
export function conflict<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 410 Gone error
|
||||
@@ -155,7 +166,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
|
||||
*/
|
||||
export function resourceGone(message?: string, data?: any): BoomError;
|
||||
export function resourceGone<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 411 Length Required error
|
||||
@@ -163,7 +174,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
|
||||
*/
|
||||
export function lengthRequired(message?: string, data?: any): BoomError;
|
||||
export function lengthRequired<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 412 Precondition Failed error
|
||||
@@ -171,7 +182,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
|
||||
*/
|
||||
export function preconditionFailed(message?: string, data?: any): BoomError;
|
||||
export function preconditionFailed<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 413 Request Entity Too Large error
|
||||
@@ -179,7 +190,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
|
||||
*/
|
||||
export function entityTooLarge(message?: string, data?: any): BoomError;
|
||||
export function entityTooLarge<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 414 Request-URI Too Large error
|
||||
@@ -187,7 +198,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
|
||||
*/
|
||||
export function uriTooLong(message?: string, data?: any): BoomError;
|
||||
export function uriTooLong<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 415 Unsupported Media Type error
|
||||
@@ -195,7 +206,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
|
||||
*/
|
||||
export function unsupportedMediaType(message?: string, data?: any): BoomError;
|
||||
export function unsupportedMediaType<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 416 Requested Range Not Satisfiable error
|
||||
@@ -203,7 +214,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
|
||||
*/
|
||||
export function rangeNotSatisfiable(message?: string, data?: any): BoomError;
|
||||
export function rangeNotSatisfiable<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 417 Expectation Failed error
|
||||
@@ -211,7 +222,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
|
||||
*/
|
||||
export function expectationFailed(message?: string, data?: any): BoomError;
|
||||
export function expectationFailed<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 418 I'm a Teapot error
|
||||
@@ -219,7 +230,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
|
||||
*/
|
||||
export function teapot(message?: string, data?: any): BoomError;
|
||||
export function teapot<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 422 Unprocessable Entity error
|
||||
@@ -227,7 +238,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
|
||||
*/
|
||||
export function badData(message?: string, data?: any): BoomError;
|
||||
export function badData<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 423 Locked error
|
||||
@@ -235,7 +246,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
|
||||
*/
|
||||
export function locked(message?: string, data?: any): BoomError;
|
||||
export function locked<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 428 Precondition Required error
|
||||
@@ -243,7 +254,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
|
||||
*/
|
||||
export function preconditionRequired(message?: string, data?: any): BoomError;
|
||||
export function preconditionRequired<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 429 Too Many Requests error
|
||||
@@ -251,7 +262,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
|
||||
*/
|
||||
export function tooManyRequests(message?: string, data?: any): BoomError;
|
||||
export function tooManyRequests<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 451 Unavailable For Legal Reasons error
|
||||
@@ -259,7 +270,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
|
||||
*/
|
||||
export function illegal(message?: string, data?: any): BoomError;
|
||||
export function illegal<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
// 5xx
|
||||
/**
|
||||
@@ -269,7 +280,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
export function badImplementation(message?: string, data?: any): BoomError;
|
||||
export function badImplementation<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 500 Internal Server Error error
|
||||
@@ -278,7 +289,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
export function internal(message?: string, data?: any): BoomError;
|
||||
export function internal<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 501 Not Implemented error with your error message to the user
|
||||
@@ -286,7 +297,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
|
||||
*/
|
||||
export function notImplemented(message?: string, data?: any): BoomError;
|
||||
export function notImplemented<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 502 Bad Gateway error with your error message to the user
|
||||
@@ -294,7 +305,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
|
||||
*/
|
||||
export function badGateway(message?: string, data?: any): BoomError;
|
||||
export function badGateway<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 503 Service Unavailable error with your error message to the user
|
||||
@@ -302,7 +313,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
|
||||
*/
|
||||
export function serverUnavailable(message?: string, data?: any): BoomError;
|
||||
export function serverUnavailable<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 504 Gateway Time-out error with your error message to the user
|
||||
@@ -310,5 +321,5 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
|
||||
*/
|
||||
export function gatewayTimeout(message?: string, data?: any): BoomError;
|
||||
export function gatewayTimeout<Data>(message?: string, data?: Data): BoomError<Data>;
|
||||
}
|
||||
|
||||
2
types/catbox/index.d.ts
vendored
2
types/catbox/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/hapijs/catbox
|
||||
// Definitions by: Jason Swearingen <http://github.com/jasonswearingen>, AJP <https://github.com/AJamesPhillips>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Boom from 'boom';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user