diff --git a/types/h2o2/h2o2-tests.ts b/types/h2o2/h2o2-tests.ts index 9d0a590fa8..9da2899258 100644 --- a/types/h2o2/h2o2-tests.ts +++ b/types/h2o2/h2o2-tests.ts @@ -140,6 +140,18 @@ const badProtocolDemo: hapi.ServerRoute = { } }; +const replyViaToolkit: hapi.ServerRoute = { + method: 'GET', + path: '/', + async handler(req, h): Promise { + return h.proxy({ + host: '10.33.33.1', + port: '443', + protocol: 'https' + }); + } +}; + if (!module.parent) { main().then(() => console.log('done'), err => console.error(err.stack)); } diff --git a/types/h2o2/index.d.ts b/types/h2o2/index.d.ts index b6e5145eb6..58be5eb271 100644 --- a/types/h2o2/index.d.ts +++ b/types/h2o2/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for h2o2 8.1 // Project: https://github.com/hapijs/h2o2 -// Definitions by: Jason Swearingen , AJP +// Definitions by: Jason Swearingen , AJP , Garth Kidd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -83,13 +83,17 @@ declare namespace h2o2 { declare module 'hapi' { interface HandlerDecorations { - /** Proxies the request to an upstream endpoint */ + /** + * Proxies the request to an upstream endpoint. + */ proxy?: h2o2.ProxyHandlerOptions; } interface ResponseToolkit { - /** Proxies the request to an upstream endpoint */ - proxy(options: h2o2.ProxyHandlerOptions): void; + /** + * Proxies the request to an upstream endpoint. `async`, so you'll need to `await` the `ResponseObject` to work on it before returning it. + */ + proxy(options: h2o2.ProxyHandlerOptions): Promise; } }