Skip to content

Commit

Permalink
APM: Explicitly type Setup to prevent hitting TS limits
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Nov 14, 2019
1 parent d123c35 commit ef912fc
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions x-pack/legacy/plugins/apm/server/lib/helpers/setup_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
import { Legacy } from 'kibana';
import { Server } from 'hapi';
import moment from 'moment';
import { KibanaConfig } from 'src/legacy/server/kbn_server';
import { getESClient } from './es_client';
import { getUiFiltersES } from './convert_ui_filters/get_ui_filters_es';
import { PromiseReturnType } from '../../../typings/common';
import { getApmIndices } from '../settings/apm_indices/get_apm_indices';
import {
getApmIndices,
ApmIndicesConfig
} from '../settings/apm_indices/get_apm_indices';
import { ESFilter } from '../../../typings/elasticsearch';
import { ESClient } from './es_client';

function decodeUiFilters(server: Server, uiFiltersEncoded?: string) {
if (!uiFiltersEncoded) {
Expand All @@ -26,9 +31,20 @@ export interface APMRequestQuery {
end?: string;
uiFilters?: string;
}
// Explicitly type Setup to prevent TS initialization errors
// https://github.com/microsoft/TypeScript/issues/34933

export type Setup = PromiseReturnType<typeof setupRequest>;
export async function setupRequest(req: Legacy.Request) {
export interface Setup {
start: number;
end: number;
uiFiltersES: ESFilter[];
client: ESClient;
internalClient: ESClient;
config: KibanaConfig;
indices: ApmIndicesConfig;
}

export async function setupRequest(req: Legacy.Request): Promise<Setup> {
const query = (req.query as unknown) as APMRequestQuery;
const { server } = req;
const savedObjectsClient = server.savedObjects.getScopedSavedObjectsClient(
Expand Down

0 comments on commit ef912fc

Please sign in to comment.