@types/boom
- Version 7.3.5
- Published
- 19.7 kB
- No dependencies
- MIT license
Install
npm i @types/boom
yarn add @types/boom
pnpm add @types/boom
Overview
TypeScript definitions for boom
Index
Functions
- badData()
- badGateway()
- badImplementation()
- badRequest()
- boomify()
- clientTimeout()
- conflict()
- entityTooLarge()
- expectationFailed()
- failedDependency()
- forbidden()
- gatewayTimeout()
- illegal()
- internal()
- isBoom()
- lengthRequired()
- locked()
- methodNotAllowed()
- notAcceptable()
- notFound()
- notImplemented()
- paymentRequired()
- preconditionFailed()
- preconditionRequired()
- proxyAuthRequired()
- rangeNotSatisfiable()
- resourceGone()
- serverUnavailable()
- teapot()
- tooManyRequests()
- unauthorized()
- unsupportedMediaType()
- uriTooLong()
Classes
Interfaces
Functions
function badData
badData: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 422 Unprocessable Entity error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function badGateway
badGateway: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 502 Bad Gateway error with your error message to the user
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function badImplementation
badImplementation: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 500 Internal Server Error error Only 500 errors will hide your message from the end user. Your message is recorded in the server log.
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function badRequest
badRequest: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 400 Bad Request error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function boomify
boomify: ( error: Error, options?: { statusCode?: number | undefined; message?: string | undefined; override?: boolean | undefined; }) => Boom<null>;
Decorates an error with the boom properties
Parameter error
the error object to wrap. If error is already a boom object, it defaults to overriding the object with the new status code and message.
Parameter options
optional additional options
See Also
function clientTimeout
clientTimeout: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 408 Request Time-out error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function conflict
conflict: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 409 Conflict error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function entityTooLarge
entityTooLarge: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 413 Request Entity Too Large error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function expectationFailed
expectationFailed: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 417 Expectation Failed error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function failedDependency
failedDependency: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 424 Failed Dependency error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function forbidden
forbidden: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 403 Forbidden error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function gatewayTimeout
gatewayTimeout: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 504 Gateway Time-out error with your error message to the user
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function illegal
illegal: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 451 Unavailable For Legal Reasons error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function internal
internal: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 500 Internal Server Error error Only 500 errors will hide your message from the end user. Your message is recorded in the server log.
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function isBoom
isBoom: (error: Error) => error is Boom<any>;
Identifies whether an error is a Boom object. Same as calling instanceof Boom.
Parameter error
the error object to identify.
function lengthRequired
lengthRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 411 Length Required error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function locked
locked: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 423 Locked error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function methodNotAllowed
methodNotAllowed: <Data = null>( message?: string, data?: Data, allow?: string | string[]) => Boom<Data>;
Returns a 405 Method Not Allowed error
Parameter message
optional message.
Parameter data
optional additional error data.
Parameter allow
optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
See Also
function notAcceptable
notAcceptable: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 406 Not Acceptable error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function notFound
notFound: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 404 Not Found error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function notImplemented
notImplemented: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 501 Not Implemented error with your error message to the user
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function paymentRequired
paymentRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 402 Payment Required error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function preconditionFailed
preconditionFailed: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 412 Precondition Failed error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function preconditionRequired
preconditionRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 428 Precondition Required error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function proxyAuthRequired
proxyAuthRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 407 Proxy Authentication Required error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function rangeNotSatisfiable
rangeNotSatisfiable: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 416 Requested Range Not Satisfiable error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function resourceGone
resourceGone: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 410 Gone error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function serverUnavailable
serverUnavailable: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 503 Service Unavailable error with your error message to the user
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function teapot
teapot: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 418 I'm a Teapot error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function tooManyRequests
tooManyRequests: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 429 Too Many Requests error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function unauthorized
unauthorized: { ( message?: string, scheme?: string, attributes?: { [index: string]: string } ): Boom<null>; (message?: string, scheme?: string[]): Boom<null>; ( message?: null, scheme?: string, attributes?: string | { [index: string]: string } ): Boom<null>;};
Returns a 401 Unauthorized error
Parameter message
optional message.
Parameter scheme
can be one of the following: * an authentication scheme name * an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header.
Parameter 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 Also
function unsupportedMediaType
unsupportedMediaType: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 415 Unsupported Media Type error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
function uriTooLong
uriTooLong: <Data = null>(message?: string, data?: Data) => Boom<Data>;
Returns a 414 Request-URI Too Large error
Parameter message
optional message.
Parameter data
optional additional error data.
See Also
Classes
class Boom
class Boom<Data = any> extends Error {}
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 Also
constructor
constructor(message?: string | Error, options?: Boom.Options<Data>);
Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties.
property data
data: {};
https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99
property isBoom
isBoom: boolean;
isBoom - if true, indicates this is a Boom object instance.
property isMissing
isMissing?: boolean;
"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 Also
property isServer
isServer: boolean;
isServer - convenience bool indicating status code >= 500.
property message
message: string;
message - the error message.
property output
output: Boom.Output;
output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys:
property typeof
readonly typeof: () => any;
typeof - the constructor used to create the error (e.g. Boom.badRequest).
method reformat
reformat: () => string;
reformat() - rebuilds error.output using the other object properties.
Interfaces
interface Options
interface Options<Data> {}
property ctor
ctor?: any;
ctor - constructor reference used to crop the exception call stack output.
property data
data?: Data | undefined;
data - additional error information (assigned to error.data).
property decorate
decorate?: object | undefined;
decorate - an option with extra properties to set on the error object.
property message
message?: string | undefined;
message - error message string. If the error already has a message, the provided message is added as a prefix. Defaults to no message.
property override
override?: boolean | undefined;
override - if false, the err provided is a Boom object, and a statusCode or message are provided, the values are ignored. Defaults to true (apply the provided statusCode and message options to the error regardless of its type, Error or Boom object).
property statusCode
statusCode?: number | undefined;
statusCode - the HTTP status code. Defaults to 500 if no status code is already set.
interface Output
interface Output {}
property headers
headers: { [index: string]: string };
headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 )
property payload
payload: Payload;
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:
property statusCode
statusCode: number;
statusCode - the HTTP status code (typically 4xx or 5xx).
interface Payload
interface Payload {}
property attributes
attributes?: any;
"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)
property error
error: string;
error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode.
property message
message: string;
message - the error message derived from error.message.
property statusCode
statusCode: number;
statusCode - the HTTP status code, derived from error.output.statusCode.
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/boom
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/boom)
- HTML<a href="https://www.jsdocs.io/package/@types/boom"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2690 ms. - Missing or incorrect documentation? Open an issue for this package.