From e01f2d7d8752ab11b8d1095bb125ac38337b5ac8 Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Wed, 21 Jun 2017 20:01:17 +0800 Subject: [PATCH 1/5] Change the type of Request.query to any instead of Object for building a fast prototype --- types/hapi/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index f0ed602864..502b8d4362 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for hapi 16.1 +// Type definitions for hapi 16.2 // Project: https://github.com/hapijs/hapi // Definitions by: Jason Swearingen , AJP // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -1938,7 +1938,7 @@ export class Request extends Podium { * an object containing the query parameters. * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 */ - query: Object; + query: any; /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ raw: { req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? From 6c2fd39fcde2a3a54a64f6b7ec85817823a106c7 Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:35:03 +0800 Subject: [PATCH 2/5] [hapi] Added test for request.query --- types/hapi/test/request/query.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 types/hapi/test/request/query.ts diff --git a/types/hapi/test/request/query.ts b/types/hapi/test/request/query.ts new file mode 100644 index 0000000000..c6507c2da0 --- /dev/null +++ b/types/hapi/test/request/query.ts @@ -0,0 +1,14 @@ +// Added test in addition to docs, for request.query + +import * as Hapi from 'hapi'; + +interface GetThingQuery { + name: string; +} + +const handler: Hapi.RouteHandler = function (request, reply) { + + const query = request.query as GetThingQuery; + + return reply(`You asked for ${query.name}`); +}; From 161f65a1939e009ace1c1514fe2bfee234f087be Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:36:04 +0800 Subject: [PATCH 3/5] [hapi] Updated docstring of request.query to the latest docs --- types/hapi/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 502b8d4362..c03d6a954b 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1935,8 +1935,9 @@ export class Request extends Podium { /** same as pre but represented as the response object created by the pre method. */ preResponses: Object; /** - * an object containing the query parameters. - * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 + * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. + * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be + * a string (if url is set to an object with the query attribute as an unparsed string). */ query: any; /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ From 0c95065c18c63b7354ed2821ddeee2067fe2b9cc Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:40:51 +0800 Subject: [PATCH 4/5] [hapi] Keep the version number of type definition as 16.1 --- types/hapi/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index c03d6a954b..91432e1d1f 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for hapi 16.2 +// Type definitions for hapi 16.1 // Project: https://github.com/hapijs/hapi // Definitions by: Jason Swearingen , AJP // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 94f1d2c48ea5b459bd23bf1e3e0a160f86756343 Mon Sep 17 00:00:00 2001 From: mailto1587 Date: Thu, 22 Jun 2017 19:43:15 +0800 Subject: [PATCH 5/5] Add the test file for request.query to tsconfig.json --- types/hapi/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/hapi/tsconfig.json b/types/hapi/tsconfig.json index 01c5a12c89..39ff8e810c 100644 --- a/types/hapi/tsconfig.json +++ b/types/hapi/tsconfig.json @@ -35,6 +35,7 @@ "test/request/generate-response.ts", "test/request/get-log.ts", "test/request/log.ts", + "test/request/query.ts", "test/request/set-method.ts", "test/request/set-url.ts", "test/request/tail.ts",