Creating namespace Lifecycle and moving FailAction to inside.

This commit is contained in:
rafaelsouzaf
2017-11-28 21:44:54 -03:00
parent 3907d25ab7
commit 55e66bcf7d
2 changed files with 39 additions and 28 deletions
-4
View File
@@ -1,4 +0,0 @@
// TODO It should be replaced by FailAction definition (with lifecycle method) in the future.
// https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-failAction
export type FailAction = 'error' | 'log' | 'ignore' | any;
+39 -24
View File
@@ -1,28 +1,43 @@
/**
* Lifecycle methods are the interface between the framework and the application. Many of the request lifecycle steps:
* extensions, authentication, handlers, pre-handler methods, and failAction function values are lifecyle methods
* provided by the developer and executed by the framework.
* Each lifecycle method is a function with the signature await function(request, h, [err]) where:
* * request - the request object.
* * h - the response toolkit the handler must call to set a response and return control back to the framework.
* * err - an error object availble only when the method is used as a failAction value.
*/
export interface LifecycleMethod {
export namespace Lifecycle {
// TODO need to be implemented. Ideally with Generics types.
/**
* Lifecycle methods are the interface between the framework and the application. Many of the request lifecycle steps:
* extensions, authentication, handlers, pre-handler methods, and failAction function values are lifecyle methods
* provided by the developer and executed by the framework.
* Each lifecycle method is a function with the signature await function(request, h, [err]) where:
* * request - the request object.
* * h - the response toolkit the handler must call to set a response and return control back to the framework.
* * err - an error object availble only when the method is used as a failAction value.
*/
export interface LifecycleMethod {
// TODO needs to be implemented.
}
/**
* Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns
* 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 LifecycleReturnValue {
// TODO needs to be implemented.
}
/**
* 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:
* * 'error' - return the error object as the response.
* * 'log' - report the error but continue processing the request.
* * 'ignore' - take no action and continue processing the request.
* * a lifecycle method with the signature async function(request, h, err) where:
* * * request - the request object.
* * * h - the response toolkit.
* * * err - the error object.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-failaction-configuration)
*/
export type FailAction = 'error' | 'log' | 'ignore' | LifecycleMethod;
}
/**
* Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns
* 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 LifecycleReturnValue {
}