Skip to content

Commit

Permalink
Change method of using Hapi RouteOptionsApp interface
Browse files Browse the repository at this point in the history
In my last commit I was extending this interface -- however, that
could conceivably cause issues in the future for other areas in the
project that need to use the route "app" options. Instead, now I am
using TypeScript "Declaration Merging" like other Kibana components
that need to interact with Hapi do.
  • Loading branch information
jportner committed Nov 5, 2019
1 parent e143e48 commit 7bc88ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/core/server/http/router/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { Url } from 'url';
import { Request, RouteOptionsApp } from 'hapi';
import { Request } from 'hapi';

import { ObjectType, TypeOf } from '@kbn/config-schema';

Expand Down Expand Up @@ -150,7 +150,7 @@ export class KibanaRequest<Params = unknown, Query = unknown, Body = unknown> {

private getRouteInfo() {
const request = this[requestSymbol];
const app = request.route.settings.app as KibanaRouteOptionsApp;
const app = request.route.settings.app;
return {
path: request.path,
method: request.method,
Expand Down Expand Up @@ -189,11 +189,3 @@ function isRequest(request: any): request is LegacyRequest {
export function isRealRequest(request: unknown): request is KibanaRequest | LegacyRequest {
return isKibanaRequest(request) || isRequest(request);
}

/**
* Extend the Hapi interface for application-specific configuration on routes
* @internal
*/
interface KibanaRouteOptionsApp extends RouteOptionsApp {
extendsSession: boolean;
}
8 changes: 8 additions & 0 deletions src/legacy/server/kbn_server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ declare module 'hapi' {
interface ResponseToolkit {
renderAppWithDefaultConfig(app: UiApp): ResponseObject;
}

/**
* Extend the Hapi interface for application-specific configuration on routes
* @internal
*/
interface RouteOptionsApp {
extendsSession: boolean;
}
}

type KbnMixinFunc = (kbnServer: KbnServer, server: Server, config: any) => Promise<any> | void;
Expand Down

0 comments on commit 7bc88ed

Please sign in to comment.