From 87156fde6b23db3d1cb7c37316807fc80f440776 Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Tue, 16 May 2017 04:19:15 +0200 Subject: [PATCH 1/8] fixed `ext` option and narrowed the type, fixed `compression` being mandatory --- types/hapi/index.d.ts | 50 ++++++++++++++++----- types/hapi/test/route/additional-options.ts | 29 ++++++++++++ types/hapi/test/route/config.ts | 2 + types/hapi/test/server/ext.ts | 4 +- 4 files changed, 73 insertions(+), 12 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 3567e50c34..2d5ee18785 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -262,8 +262,10 @@ export class Server extends Podium { * [See docs](https://hapijs.com/api/16.1.1#serverextevents) * @param events see @ServerExtConfigurationObject */ - ext(events: ServerExtConfigurationObject[]): void; - ext(events: ServerExtConfigurationObject): void; + ext(events: ServerStartExtConfigurationObject): void; + ext(events: ServerStartExtConfigurationObject[]): void; + ext(events: ServerRequestExtConfigurationObjectWithRequest): void; + ext(events: ServerRequestExtConfigurationObjectWithRequest[]): void; /** * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. * [See docs](https://hapijs.com/api/16.1.1#serverextevent-method-options) @@ -271,8 +273,10 @@ export class Server extends Podium { * @param method a function or an array of functions to be executed at a specified point during request processing. * @param options */ - ext(event: ServerExtPoints, method: ServerExtMethod[], options?: ServerExtOptions): void; - ext(event: ServerExtPoints, method: ServerExtMethod, options?: ServerExtOptions): void; + ext(event: ServerStartExtPoints, method: ServerExtFunction[], options?: ServerExtOptions): void; + ext(event: ServerStartExtPoints, method: ServerExtFunction, options?: ServerExtOptions): void; + ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler[], options?: ServerExtOptions): void; + ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler, options?: ServerExtOptions): void; /** * Registers a new handler type to be used in routes * The method function can have a defaults object or function property. If the property is set to an object, that object is used as the default route config for routes using this handler. If the property is set to a function, the function uses the signature function(method) and returns the route default configuration. @@ -880,16 +884,40 @@ export interface CorsConfigurationObject { * [See docs](https://hapijs.com/api/16.1.1#serverextevents) * For context see RouteAdditionalConfigurationOptions > ext */ -export interface ServerExtConfigurationObject { + +// STUFF +export interface ServerStartExtConfigurationObject { /** the extension point event name. */ - type: ServerExtPoints; + type: ServerStartExtPoints; /** * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler */ - method: ServerExtMethod | ServerExtMethod[]; + method: ServerExtFunction options?: ServerExtOptions; } +export interface ServerRequestExtConfigurationObject { + /** the extension point event name. */ + type: ServerRequestExtPointsBase; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtRequestHandler + options?: ServerExtOptions; +} + +export interface ServerRequestExtConfigurationObjectWithRequest { + /** the extension point event name. */ + type: ServerRequestExtPoints; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtRequestHandler + options?: ServerExtOptions; +} + +export type RouteExtConfigurationObject = ServerStartExtConfigurationObject | ServerRequestExtConfigurationObject; + /** * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > method */ @@ -918,7 +946,9 @@ export interface ServerExtOptions { * * 'onPostStop' - called after the connection listeners are stopped. * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type */ -export type ServerExtPoints = 'onRequest' | 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse' | 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; +export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; /** * Server extension function registered an one of the server extension points @@ -985,7 +1015,7 @@ export interface RoutePayloadConfigurationObject { /** the default 'Content-Type' HTTP header value is not present. Defaults to 'application/json'. */ defaultContentType?: string; /** 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 the root option compression. */ - compression: Dictionary; + compression?: Dictionary; } export type PayLoadOutputOption = 'data' | 'stream' | 'file'; @@ -1079,7 +1109,7 @@ export interface RouteAdditionalConfigurationOptions { /** the Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. CORS headers are disabled by default (false). To enable, set cors to true, or to an object */ cors?: boolean | CorsConfigurationObject; /** defined a route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the [server.ext(events)](https://hapijs.com/api/16.1.1#serverextevents) event argument. */ - ext?: Dictionary; + ext?: RouteExtConfigurationObject | RouteExtConfigurationObject[]; /** defines the behavior for accessing files: */ files?: { /** determines the folder relative paths are resolved against. */ diff --git a/types/hapi/test/route/additional-options.ts b/types/hapi/test/route/additional-options.ts index 99e818d08a..074b9cc155 100644 --- a/types/hapi/test/route/additional-options.ts +++ b/types/hapi/test/route/additional-options.ts @@ -6,6 +6,29 @@ var authConfig: Hapi.RouteAdditionalConfigurationOptions = { app: {} }; +var extConfigSingle: Hapi.RouteAdditionalConfigurationOptions = { + ext: { + type: 'onPreAuth', + method: function (request, reply) { + reply('ok'); + } + } +} + +var extConfigMulti: Hapi.RouteAdditionalConfigurationOptions = { + ext: [{ + type: 'onPreAuth', + method: function (request, reply) { + reply('ok'); + } + }, { + type: 'onPostAuth', + method: function (request, reply) { + reply('ok'); + } + }] +} + // Handler in config const user: Hapi.RouteAdditionalConfigurationOptions = { cache: { expiresIn: 5000, statuses: [200, 201] }, @@ -37,3 +60,9 @@ var cache: Hapi.RouteCacheOptions = { expiresAt: '22:44', }; */ + +var payloadOptions: Hapi.RoutePayloadConfigurationObject = { + allow: 'multipart/form-data', + maxBytes: 123, + output: 'file', +}; diff --git a/types/hapi/test/route/config.ts b/types/hapi/test/route/config.ts index 16457395f8..562534b650 100644 --- a/types/hapi/test/route/config.ts +++ b/types/hapi/test/route/config.ts @@ -43,4 +43,6 @@ const user: Hapi.RouteAdditionalConfigurationOptions = { } }; + + server.route({method: 'GET', path: '/user', config: user }); diff --git a/types/hapi/test/server/ext.ts b/types/hapi/test/server/ext.ts index 410c913c41..500ac1d4af 100644 --- a/types/hapi/test/server/ext.ts +++ b/types/hapi/test/server/ext.ts @@ -7,7 +7,7 @@ server.connection({ port: 80 }); server.ext({ type: 'onRequest', - method: function (request, reply) { + method: function (request, reply) { // Change all requests to '/test' request.setUrl('/test'); @@ -28,7 +28,7 @@ server.start((err) => { }); // Example 2 -server.ext('onRequest', function (request, reply) { +server.ext('onRequest', function (request, reply) { // Change all requests to '/test' request.setUrl('/test'); From 2d2f11dd8d31bcee5a923f87559c4045d92729fb Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Tue, 16 May 2017 04:24:20 +0200 Subject: [PATCH 2/8] rm additional whitespace --- types/hapi/test/route/config.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/hapi/test/route/config.ts b/types/hapi/test/route/config.ts index 562534b650..16457395f8 100644 --- a/types/hapi/test/route/config.ts +++ b/types/hapi/test/route/config.ts @@ -43,6 +43,4 @@ const user: Hapi.RouteAdditionalConfigurationOptions = { } }; - - server.route({method: 'GET', path: '/user', config: user }); From 8b328fa9ab3bf6a56351058a21633080eec6ff09 Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Tue, 16 May 2017 04:53:30 +0200 Subject: [PATCH 3/8] amend route plugins --- types/hapi/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 2d5ee18785..9bc1807623 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -477,6 +477,8 @@ export class Server extends Podium { table(host?: string): RoutingTableEntry[]; } +export interface RoutePlugins {} + /** * Server Options * Note that the options object is deeply cloned and cannot contain any values that are unsafe to perform deep copy on. @@ -509,7 +511,7 @@ export interface ServerOptions { /** 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?: MimosOptions; /** 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?: Object; + plugins?: RoutePlugins; /** if false, will not use node domains to protect against exceptions thrown in handlers and other external code. Defaults to true. */ useDomains?: boolean; } From ac46bea13a0a41bdcc8f5fe50f563c3df354389a Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Tue, 16 May 2017 13:47:24 +0200 Subject: [PATCH 4/8] address comments --- types/hapi/index.d.ts | 34 +++++++++++----- types/hapi/test/route/additional-options.ts | 44 ++++++++++++--------- types/hapi/test/route/plugins.ts | 18 +++++++++ types/hapi/tsconfig.json | 3 +- 4 files changed, 69 insertions(+), 30 deletions(-) create mode 100644 types/hapi/test/route/plugins.ts diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 9bc1807623..4e855f4540 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -886,8 +886,6 @@ export interface CorsConfigurationObject { * [See docs](https://hapijs.com/api/16.1.1#serverextevents) * For context see RouteAdditionalConfigurationOptions > ext */ - -// STUFF export interface ServerStartExtConfigurationObject { /** the extension point event name. */ type: ServerStartExtPoints; @@ -898,26 +896,39 @@ export interface ServerStartExtConfigurationObject { options?: ServerExtOptions; } +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ export interface ServerRequestExtConfigurationObject { /** the extension point event name. */ type: ServerRequestExtPointsBase; /** * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler */ - method: ServerExtRequestHandler + method: ServerExtRequestHandler | ServerExtRequestHandler[] options?: ServerExtOptions; } +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ export interface ServerRequestExtConfigurationObjectWithRequest { /** the extension point event name. */ type: ServerRequestExtPoints; /** * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler */ - method: ServerExtRequestHandler + method: ServerExtRequestHandler | ServerExtRequestHandler[]; options?: ServerExtOptions; } +/** + * [See docs](https://hapijs.com/api/16.1.1#route-configuration) > ext + */ export type RouteExtConfigurationObject = ServerStartExtConfigurationObject | ServerRequestExtConfigurationObject; /** @@ -940,16 +951,19 @@ export interface ServerExtOptions { } /** - * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) - * The available extension points include the request extension points as well as the following server extension points: + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type * * 'onPreStart' - called before the connection listeners are started. * * 'onPostStart' - called after the connection listeners are started. * * 'onPreStop' - called before the connection listeners are stopped. * * 'onPostStop' - called after the connection listeners are stopped. - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type */ export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +/** + * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) + * * The available extension points include the request extension points as well as the following server extension points: + */ export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; + export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; /** @@ -2033,11 +2047,11 @@ export interface RequestHandler { /** * Used by server extension points * err can be BoomError or Error that will be wrapped as a BoomError - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118) - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) + * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118) + * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) */ export interface ContinuationFunction { - (err: Boom.BoomError): void; + (err?: Boom.BoomError): void; } /** * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) diff --git a/types/hapi/test/route/additional-options.ts b/types/hapi/test/route/additional-options.ts index 074b9cc155..124766c721 100644 --- a/types/hapi/test/route/additional-options.ts +++ b/types/hapi/test/route/additional-options.ts @@ -3,29 +3,35 @@ import * as Hapi from 'hapi'; var authConfig: Hapi.RouteAdditionalConfigurationOptions = { - app: {} + app: {}, + payload: {}, }; var extConfigSingle: Hapi.RouteAdditionalConfigurationOptions = { - ext: { - type: 'onPreAuth', - method: function (request, reply) { - reply('ok'); + ext: { + type: 'onPreAuth', + method: function (request, reply) { + reply('ok'); + } } - } } var extConfigMulti: Hapi.RouteAdditionalConfigurationOptions = { - ext: [{ - type: 'onPreAuth', - method: function (request, reply) { - reply('ok'); - } - }, { - type: 'onPostAuth', - method: function (request, reply) { - reply('ok'); - } + ext: [{ + type: 'onPreAuth', + method: function (request, reply) { + reply('ok'); + } + }, { + type: 'onPostAuth', + method: function (request, reply) { + reply('ok'); + } + }, { + type: 'onPostStart', + method: function (server, next) { + next(); + } }] } @@ -62,7 +68,7 @@ var cache: Hapi.RouteCacheOptions = { */ var payloadOptions: Hapi.RoutePayloadConfigurationObject = { - allow: 'multipart/form-data', - maxBytes: 123, - output: 'file', + allow: 'multipart/form-data', + maxBytes: 123, + output: 'file', }; diff --git a/types/hapi/test/route/plugins.ts b/types/hapi/test/route/plugins.ts new file mode 100644 index 0000000000..94245238ee --- /dev/null +++ b/types/hapi/test/route/plugins.ts @@ -0,0 +1,18 @@ +// from https://hapijs.com/api#route-configuration > plugins + +import * as Hapi from 'hapi'; + +declare module 'hapi' { + interface RoutePlugins { + coolPlugin: { + optionA: string; + optionB?: boolean; + } + } +} + +var pluginsConfig: Hapi.RouteAdditionalConfigurationOptions = { + plugins: { + coolPlugin: 'test', + } +}; diff --git a/types/hapi/tsconfig.json b/types/hapi/tsconfig.json index f8d5b055e2..5338f169d3 100644 --- a/types/hapi/tsconfig.json +++ b/types/hapi/tsconfig.json @@ -45,6 +45,7 @@ "test/route/auth.ts", "test/route/config.ts", "test/route/handler.ts", + "test/route/plugins.ts", "test/route/prerequisites.ts", "test/route/public-interface.ts", "test/server/app.ts", @@ -89,4 +90,4 @@ "test/server/table.ts", "test/server/version.ts" ] -} \ No newline at end of file +} From f2cf1da49cc4a647dee9f7a4a5c6bbb7a6f39ab7 Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Wed, 17 May 2017 01:22:34 +0200 Subject: [PATCH 5/8] address comments #2 --- types/hapi/index.d.ts | 2 +- types/hapi/test/route/additional-options.ts | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 4e855f4540..59e7748bc6 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -892,7 +892,7 @@ export interface ServerStartExtConfigurationObject { /** * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler */ - method: ServerExtFunction + method: ServerExtFunction | ServerExtFunction[]; options?: ServerExtOptions; } diff --git a/types/hapi/test/route/additional-options.ts b/types/hapi/test/route/additional-options.ts index 124766c721..aaf5a33066 100644 --- a/types/hapi/test/route/additional-options.ts +++ b/types/hapi/test/route/additional-options.ts @@ -20,18 +20,18 @@ var extConfigMulti: Hapi.RouteAdditionalConfigurationOptions = { ext: [{ type: 'onPreAuth', method: function (request, reply) { - reply('ok'); - } - }, { - type: 'onPostAuth', - method: function (request, reply) { - reply('ok'); + reply('ok'); } }, { - type: 'onPostStart', - method: function (server, next) { - next(); - } + type: 'onPostAuth', + method: function (request, reply) { + reply('ok'); + } + }, { + type: 'onPostStart', + method: function (server, next) { + next(); + } }] } @@ -39,7 +39,6 @@ var extConfigMulti: Hapi.RouteAdditionalConfigurationOptions = { const user: Hapi.RouteAdditionalConfigurationOptions = { cache: { expiresIn: 5000, statuses: [200, 201] }, handler: function (request, reply) { - return reply({ name: 'John' }); } }; From 95144bb2479d24bb1a39c74d7411f575adf29038 Mon Sep 17 00:00:00 2001 From: Alexander James Phillips Date: Tue, 16 May 2017 23:27:51 +0100 Subject: [PATCH 6/8] Include Plugin specific config for route server and connection level --- types/hapi/index.d.ts | 8 ++++---- types/hapi/test/route/plugins.ts | 28 ++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 59e7748bc6..0abdf534e9 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -477,7 +477,7 @@ export class Server extends Podium { table(host?: string): RoutingTableEntry[]; } -export interface RoutePlugins {} +export interface PluginSpecificConfiguration {} /** * Server Options @@ -511,7 +511,7 @@ export interface ServerOptions { /** 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?: MimosOptions; /** 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?: RoutePlugins; + plugins?: PluginSpecificConfiguration; /** if false, will not use node domains to protect against exceptions thrown in handlers and other external code. Defaults to true. */ useDomains?: boolean; } @@ -724,7 +724,7 @@ export interface ConnectionConfigurationServerDefaults { maxEventLoopDelay: number; }; /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ - plugins?: any; + plugins?: PluginSpecificConfiguration; /** controls how incoming request URIs are matched against the routing table: */ router?: { /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ @@ -1152,7 +1152,7 @@ export interface RouteAdditionalConfigurationOptions { */ payload?: RoutePayloadConfigurationObject; /** plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. */ - plugins?: Object; + plugins?: PluginSpecificConfiguration; /** an array with [route prerequisites](https://hapijs.com/api/16.1.1#route-prerequisites) methods which are executed in serial or in parallel before the handler is called. */ pre?: RoutePrerequisitesArray; /** processing rules for the outgoing response */ diff --git a/types/hapi/test/route/plugins.ts b/types/hapi/test/route/plugins.ts index 94245238ee..2449fc84c0 100644 --- a/types/hapi/test/route/plugins.ts +++ b/types/hapi/test/route/plugins.ts @@ -1,9 +1,10 @@ -// from https://hapijs.com/api#route-configuration > plugins +// Added in addition to code from https://hapijs.com/api/16.1.1#route-options > plugins import * as Hapi from 'hapi'; +// In the plugin code declare module 'hapi' { - interface RoutePlugins { + interface PluginSpecificConfiguration { coolPlugin: { optionA: string; optionB?: boolean; @@ -11,8 +12,27 @@ declare module 'hapi' { } } -var pluginsConfig: Hapi.RouteAdditionalConfigurationOptions = { +// In the consumer code +const pluginsServerConfig: Hapi.ServerOptions = { plugins: { - coolPlugin: 'test', + coolPlugin: { + optionA: "test", + } + } +}; + +const pluginsConnectionConfig: Hapi.ConnectionConfigurationServerDefaults = { + plugins: { + coolPlugin: { + optionA: "test", + } + } +}; + +const pluginsRouteConfig: Hapi.RouteAdditionalConfigurationOptions = { + plugins: { + coolPlugin: { + optionA: "test", + } } }; From cbda0a036b27b0955d34b0b60971c23742c5baef Mon Sep 17 00:00:00 2001 From: Alexander James Phillips Date: Wed, 17 May 2017 12:48:26 +0100 Subject: [PATCH 7/8] Fix tests for pluginSpecificConfiguration --- types/hapi/test/server/new.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/types/hapi/test/server/new.ts b/types/hapi/test/server/new.ts index 24ac654ecd..95f1ce9006 100644 --- a/types/hapi/test/server/new.ts +++ b/types/hapi/test/server/new.ts @@ -44,6 +44,15 @@ new Hapi.Server({ }] }); +//+ Code added in addition to docs +declare module 'hapi' { + interface PluginSpecificConfiguration { + // Set this to non optional if plugin config is non optional + 'some-plugin-name'?: {options: string;}; + } +} +//- Code added in addition to docs + new Hapi.Server({ connections: { app: {}, @@ -54,7 +63,8 @@ new Hapi.Server({ maxEventLoopDelay: 10, }, plugins: { - 'some-plugin-name': {options: 'here'} + 'some-plugin-name': {options: 'here'}, + coolPlugin: {optionA: ""}, }, router: { isCaseSensitive: false, From a82323abc9b1208421f41647c5c3cef1b128e39f Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Thu, 18 May 2017 13:38:10 +0200 Subject: [PATCH 8/8] fix typo --- 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 0abdf534e9..40fae44148 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -2198,7 +2198,7 @@ export type AnyAuthenticationResponseAction = any; /** [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) */ export interface AuthenticationResult { credentials?: AuthenticatedCredentials; - artefacts?: any; + artifacts?: any; } export interface AuthenticatedCredentials { // Disabled to allow typing within a project