Going back with Dictionary. It didn't work as expected :-/

This commit is contained in:
rafaelsouzaf
2017-12-09 12:00:10 -03:00
parent aff418b46d
commit b453000bc5
9 changed files with 26 additions and 19 deletions
+5 -5
View File
@@ -54,7 +54,7 @@ export interface Request extends Podium {
* The raw request headers (references request.raw.req.headers).
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestheaders)
*/
readonly headers: Map<string, string>;
readonly headers: Util.Dictionary<string>;
/**
* Request information:
@@ -98,7 +98,7 @@ export interface Request extends Podium {
/**
* An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters).
*/
readonly params: Map<string, string>;
readonly params: Util.Dictionary<string>;
/**
* An array containing all the path params values in the order they appeared in the path.
@@ -124,7 +124,7 @@ export interface Request extends Podium {
/**
* An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses.
*/
readonly pre: Map<string, object>;
readonly pre: Util.Dictionary<object>;
/**
* Access: read / write (see limitations below).
@@ -135,7 +135,7 @@ export interface Request extends Podium {
/**
* Same as pre but represented as the response object created by the pre method.
*/
readonly preResponses: Map<string, object>;
readonly preResponses: Util.Dictionary<object>;
/**
* By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string).
@@ -168,7 +168,7 @@ export interface Request extends Podium {
/**
* An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition.
*/
readonly state: Map<string, any>;
readonly state: Util.Dictionary<any>;
/**
* The parsed request URI.
+2 -2
View File
@@ -1,5 +1,5 @@
import * as Podium from "podium";
import {Json, Lifecycle, PluginsStates, ResponseEvents, ResponseSettings, ServerStateCookieOptions} from "hapi";
import {Json, Lifecycle, PluginsStates, ResponseEvents, ResponseSettings, ServerStateCookieOptions, Util} from "hapi";
/**
* Object where:
@@ -48,7 +48,7 @@ export interface ResponseObject extends Podium {
* Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders)
*/
readonly headers: Map<string, string | string[]>;
readonly headers: Util.Dictionary<string | string[]>;
/**
* Default value: {}.
@@ -1,4 +1,4 @@
import {Lifecycle} from "hapi";
import {Lifecycle, Util} from "hapi";
/**
* The value must be one of:
@@ -38,7 +38,7 @@ export interface RouteOptionsPayload {
* An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression)
*/
compression?: Map<string, PayloadCompressionDecoderSettings>;
compression?: Util.Dictionary<PayloadCompressionDecoderSettings>;
/**
* Default value: 'application/json'.
@@ -1,4 +1,4 @@
import {Lifecycle} from "hapi";
import {Lifecycle, Util} from "hapi";
import {ValidationOptions} from "joi";
/**
@@ -79,6 +79,6 @@ export interface RouteOptionsResponse {
* status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus)
*/
status?: Map<number, RouteOptionsResponseSchema>;
status?: Util.Dictionary<RouteOptionsResponseSchema>;
}
+4 -3
View File
@@ -9,7 +9,8 @@ import {
RouteOptionsPreArray,
RouteOptionsResponse,
RouteOptionsSecure,
RouteOptionsValidate
RouteOptionsValidate,
Util
} from "hapi";
/**
@@ -66,7 +67,7 @@ export interface RouteOptions {
* An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression)
*/
compression?: Map<string, RouteCompressionEncoderSettings>;
compression?: Util.Dictionary<RouteCompressionEncoderSettings>;
/**
* Default value: false (no CORS headers).
@@ -181,7 +182,7 @@ export interface RouteOptions {
* Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins)
*/
plugins?: Map<string, PluginSpecificConfiguration>;
plugins?: Util.Dictionary<PluginSpecificConfiguration>;
/**
* Default value: none.
+2 -2
View File
@@ -1,4 +1,4 @@
import {Request, RouteOptionsAccess, ServerAuthScheme} from "hapi";
import {Request, RouteOptionsAccess, ServerAuthScheme, Util} from "hapi";
/**
* The authentication credentials object
@@ -24,7 +24,7 @@ export interface ServerAuth {
* returned from its implementation function.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi)
*/
api: Map<string, any>;
api: Util.Dictionary<any>;
/**
* Contains the default authentication configuration is a default strategy was set via
+2 -2
View File
@@ -1,4 +1,4 @@
import {ServerStateCookieOptions} from "hapi";
import {ServerStateCookieOptions, Util} from "hapi";
/**
* A single object or an array of object where each contains:
@@ -66,6 +66,6 @@ export interface ServerState {
* Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie parsing (e.g. when server parsing is disabled).
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesparseheader)
*/
parse(header: string): Map<string, string>;
parse(header: string): Util.Dictionary<string>;
}
+1 -1
View File
@@ -162,7 +162,7 @@ export class Server extends Podium {
* server method name is an object property.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods
*/
readonly methods: Map<string, ServerMethod>;
readonly methods: Util.Dictionary<ServerMethod>;
/**
* Provides access to the server MIME database used for setting content-type information. The object must not be
+6
View File
@@ -1,5 +1,11 @@
export namespace Util {
export interface Dictionary<T> {
[key: string]: T;
}
export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options';
export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE;
export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL;
}