From 12d64487d41076f45d1b3181561ff40765731397 Mon Sep 17 00:00:00 2001 From: rsouza Date: Wed, 29 Nov 2017 16:33:59 -0300 Subject: [PATCH] Added some Lifecycle definitions. --- .../hapi/v17/definitions/util/lifecycle.d.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 6501e8edd1..3cf2840199 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -1,3 +1,8 @@ +import * as Boom from "../../../../boom/index"; +import * as stream from "stream"; +import {ResponseToolkit, Request} from "hapi"; + + export namespace Lifecycle { /** @@ -10,9 +15,8 @@ export namespace Lifecycle { * * err - an error object availble only when the method is used as a failAction value. */ export interface Method { - - // TODO needs to be implemented. - + (request: Request, h: ResponseToolkit): void; + (request: Request, h: ResponseToolkit, err: Error): void; } /** @@ -20,11 +24,16 @@ export namespace Lifecycle { * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) */ - export interface ReturnValue { - - // TODO needs to be implemented. - - } + export type ReturnValue = ReturnValueTypes | (Promise); + export type ReturnValueTypes = + (null | undefined | string | number | boolean) | + (Buffer) | + (Error | Boom.BoomError) | + (stream.Stream) | + (Object | Object[]) | + // a toolkit signal: + // a toolkit method response: + any; // TODO need review /** * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be configured to perform another action. When supported the failAction option supports the following values: