diff --git a/boom/boom-tests.ts b/boom/boom-tests.ts new file mode 100644 index 0000000000..67c7786273 --- /dev/null +++ b/boom/boom-tests.ts @@ -0,0 +1,7 @@ +/// + +import Boom = require('boom'); + +Boom.create(500, 'Internal server error', { timestamp: Date.now() }); +Boom.wrap(new Error('test'), 400); +Boom.badRequest('Invalid cookies'); diff --git a/boom/boom.d.ts b/boom/boom.d.ts new file mode 100644 index 0000000000..3a3f18fa29 --- /dev/null +++ b/boom/boom.d.ts @@ -0,0 +1,32 @@ +// Type definitions for boom +// Project: http://github.com/hapijs/boom +// Definitions by: Igor Rogatty +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Boom { + interface BoomError { + data: any; + reformat: () => void; + isBoom: boolean; + isServer: boolean; + message: string; + output: Output; + } + + export interface Output { + statusCode: number; + headers: any; + payload: any; + } + + export function wrap(error: Error, statusCode?: number, message?: string): BoomError; + export function create(statusCode: number, message?: string, data?: any): BoomError; + + export function badRequest(message?: string, data?: any): BoomError; +} + +declare module "boom" { + export = Boom; +}