diff --git a/packages/kbn-server-route-repository/src/create_server_route_repository.ts b/packages/kbn-server-route-repository/src/create_server_route_repository.ts index 021dd35c1025f..5ac89ebcac77f 100644 --- a/packages/kbn-server-route-repository/src/create_server_route_repository.ts +++ b/packages/kbn-server-route-repository/src/create_server_route_repository.ts @@ -15,15 +15,23 @@ export function createServerRouteRepository< TRouteHandlerResources extends ServerRouteHandlerResources = never, TRouteCreateOptions extends ServerRouteCreateOptions = never >(): ServerRouteRepository { - const routes: Record = {}; + let routes: Record = {}; return { add(route) { - routes[route.endpoint] = route; + routes = { + ...routes, + [route.endpoint]: route, + }; + return this as any; }, merge(repository) { - Object.assign(routes, repository.getRoutes()); + routes = { + ...routes, + ...Object.fromEntries(repository.getRoutes().map((route) => [route.endpoint, route])), + }; + return this as any; }, getRoutes: () => Object.values(routes), diff --git a/x-pack/plugins/apm/public/services/rest/createCallApmApi.ts b/x-pack/plugins/apm/public/services/rest/createCallApmApi.ts index 5dc2aa6aa30da..9874703b7344d 100644 --- a/x-pack/plugins/apm/public/services/rest/createCallApmApi.ts +++ b/x-pack/plugins/apm/public/services/rest/createCallApmApi.ts @@ -6,13 +6,13 @@ */ import { CoreSetup, CoreStart } from 'kibana/public'; -import { +import type { ClientRequestParamsOf, EndpointOf, - formatRequest, ReturnOf, RouteRepositoryClient, } from '@kbn/server-route-repository'; +import { formatRequest } from '@kbn/server-route-repository/target/format_request'; import { FetchOptions } from '../../../common/fetch_options'; import { callApi } from './callApi'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/plugins/apm/server/routes/register_routes/index.ts b/x-pack/plugins/apm/server/routes/register_routes/index.ts index 0eb2928ee32a2..b8fab0cb4932b 100644 --- a/x-pack/plugins/apm/server/routes/register_routes/index.ts +++ b/x-pack/plugins/apm/server/routes/register_routes/index.ts @@ -61,6 +61,11 @@ export function registerRoutes({ const { method, pathname } = parseEndpoint(endpoint); + console.log({ + method, + pathname, + }); + (router[method] as RouteRegistrar< typeof method, ApmPluginRequestHandlerContext diff --git a/x-pack/plugins/apm/server/routes/services.ts b/x-pack/plugins/apm/server/routes/services.ts index 462200115b4bb..800a5bdcc5d5f 100644 --- a/x-pack/plugins/apm/server/routes/services.ts +++ b/x-pack/plugins/apm/server/routes/services.ts @@ -561,7 +561,7 @@ const serviceDependenciesRoute = createApmServerRoute({ }), query: t.intersection([ t.type({ - numBuckets: t.number, + numBuckets: toNumberRt, }), environmentRt, rangeRt,