@types/boom

  • Version 7.3.0
  • Published
  • 20.2 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

function badData

badData: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function badGateway

badGateway: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function badImplementation

badImplementation: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function badRequest

badRequest: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function boomify

boomify: (
error: Error,
options?: { statusCode?: number; message?: string; override?: boolean }
) => 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>;

function conflict

conflict: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function entityTooLarge

entityTooLarge: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function expectationFailed

expectationFailed: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function failedDependency

failedDependency: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function forbidden

forbidden: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function gatewayTimeout

gatewayTimeout: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function illegal

illegal: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function internal

internal: <Data = null>(message?: string, data?: Data) => Boom<Data>;

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>;

function locked

locked: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function methodNotAllowed

methodNotAllowed: <Data = null>(
message?: string,
data?: Data,
allow?: string | string[]
) => Boom<Data>;

function notAcceptable

notAcceptable: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function notFound

notFound: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function notImplemented

notImplemented: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function paymentRequired

paymentRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function preconditionFailed

preconditionFailed: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function preconditionRequired

preconditionRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function proxyAuthRequired

proxyAuthRequired: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function rangeNotSatisfiable

rangeNotSatisfiable: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function resourceGone

resourceGone: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function serverUnavailable

serverUnavailable: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function teapot

teapot: <Data = null>(message?: string, data?: Data) => Boom<Data>;

function tooManyRequests

tooManyRequests: <Data = null>(message?: string, data?: Data) => Boom<Data>;

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>;

function uriTooLong

uriTooLong: <Data = null>(message?: string, data?: Data) => Boom<Data>;

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;

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;
    • data - additional error information (assigned to error.data).

    property decorate

    decorate?: object;
    • decorate - an option with extra properties to set on the error object.

    property message

    message?: string;
    • 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;
    • 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;
    • 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 onejsDocs.io badgeto 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>