From 48de82851fc527418d3aba632e172fa0a889f3cd Mon Sep 17 00:00:00 2001 From: Adam Carr Date: Mon, 30 Mar 2015 16:19:10 -0400 Subject: [PATCH 1/3] Updating hapi.d.ts to support optional parameters when registering a plugin --- hapi/hapi-tests.ts | 6 ++++++ hapi/hapi.d.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hapi/hapi-tests.ts b/hapi/hapi-tests.ts index 058903637..c0f8d9f6e 100644 --- a/hapi/hapi-tests.ts +++ b/hapi/hapi-tests.ts @@ -21,6 +21,12 @@ plugin.register.attributes = { version: "1.0.0" }; +// optional options parameter +server.register({}, function (err) {}); + +// optional options.routes.vhost parameter +server.register({}, { select: 'api', routes: { prefix: '/prefix' } }, function (err) {}); + //server.pack.register(plugin, (err: Object) => { // if (err) { throw err; } //}); diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 61a2ef2d5..be2bf9665 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -2051,11 +2051,13 @@ declare module "hapi" { register(plugins: any|any[], options: { select: string|string[]; routes: { - prefix: string; vhost: string|string[] + prefix: string; vhost?: string|string[] }; } , callback: (err: any) => void):void; + register(plugins: any|any[], callback: (err: any) => void):void; + /**server.render(template, context, [options], callback) Utilizes the server views manager to render a template where: template - the template filename and path, relative to the views manager templates path (path or relativeTo). From 25ab55fa3c9089785ad814dd42a296c92185c553 Mon Sep 17 00:00:00 2001 From: Adam Carr Date: Mon, 30 Mar 2015 18:33:01 -0400 Subject: [PATCH 2/3] making IRouteHandlerConfig parameters optional --- hapi/hapi.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index be2bf9665..77eaf8f08 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -726,7 +726,7 @@ declare module "hapi" { a relative or absolute file path string (relative paths are resolved based on the route files configuration). a function with the signature function(request) which returns the relative or absolute file path. an object with the following options */ - file: string | IRequestHandler |IFileHandlerConfig; + file?: string | IRequestHandler |IFileHandlerConfig; /** directory - generates a directory endpoint for serving static content from a directory. Routes using the directory handler must include a path parameter at the end of the path string (e.g. /path/to/somewhere/{param} where the parameter name does not matter). The path parameter can use any of the parameter options (e.g. {param} for one level files only, {param?} for one level files or the directory root, {param*} for any level, or {param*3} for a specific level). If additional path parameters are present, they are ignored for the purpose of selecting the file system resource. The directory handler is an object with the following options: path - (required) the directory root path (relative paths are resolved based on the route files configuration). Value can be: a single path string used as the prefix for any resources requested by appending the request path parameter to the provided string. @@ -738,7 +738,7 @@ declare module "hapi" { redirectToSlash - optional boolean, determines if requests for a directory without a trailing slash are redirected to the same path with the missing slash. Useful for ensuring relative links inside the response are resolved correctly. Disabled when the server config router.stripTrailingSlash is true.Defaults to false. lookupCompressed - optional boolean, instructs the file processor to look for the same filename with the '.gz' suffix for a pre-compressed version of the file to serve if the request supports content encoding. Defaults to false. defaultExtension - optional string, appended to file requests if the requested file is not found. Defaults to no extension.*/ - directory: { + directory?: { path: string |Array | IRequestHandler | IRequestHandler>; index?: boolean; listing?: boolean; @@ -748,7 +748,7 @@ declare module "hapi" { defaultExtension?: string; }; proxy?: IProxyHandlerConfig; - view: string | { + view?: string | { template: string; context: { payload: any; @@ -757,7 +757,7 @@ declare module "hapi" { pre: any; } }; - config: { + config?: { handler: any; bind: any; app: any; From e3224233793afdbfd918512551a11952a5e7e03e Mon Sep 17 00:00:00 2001 From: Adam Carr Date: Mon, 30 Mar 2015 18:43:43 -0400 Subject: [PATCH 3/3] updating IServerOptions for optional properties --- hapi/hapi.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 77eaf8f08..2cd06cd6e 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -147,11 +147,11 @@ declare module "hapi" { }; /** options passed to the mimos module (https://github.com/hapijs/mimos) when generating the mime database used by the server and accessed via server.mime.*/ - mime: any; + mime?: any; /** if true, does not load the inert (file and directory support), h2o2 (proxy support), and vision (views support) plugins automatically. The plugins can be loaded manually after construction. Defaults to false (plugins loaded). */ - minimal: boolean; + minimal?: boolean; /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}.*/ - plugins: IDictionary; + plugins?: IDictionary; }