Skip to content

Commit

Permalink
Move validate to appropriate level of route definition object for mon…
Browse files Browse the repository at this point in the history
…itor details endpoint.
  • Loading branch information
justinkambic committed Nov 25, 2019
1 parent 8f103ea commit a45dae4
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import Joi from 'joi';

import { schema } from '@kbn/config-schema';
import { UMServerLibs } from '../../lib/lib';
import { MonitorDetails } from '../../../common/runtime_types/monitor/monitor_details';
import { UMRestApiRouteCreator } from '../types';

export const createGetMonitorDetailsRoute = (libs: UMServerLibs) => ({
export const createGetMonitorDetailsRoute: UMRestApiRouteCreator = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/monitor/details',
validate: {
query: schema.object({
monitorId: schema.maybe(schema.string()),
}),
},
options: {
validate: {
query: Joi.object({
monitorId: Joi.string(),
}),
},
tags: ['access:uptime'],
},
handler: async (request: any): Promise<MonitorDetails> => {
handler: async (_context, request, response): Promise<any> => {
const { monitorId } = request.query;
return await libs.monitors.getMonitorDetails(request, monitorId);

return response.ok({
body: { ...(await libs.monitors.getMonitorDetails(request, monitorId)) },
});
},
});

0 comments on commit a45dae4

Please sign in to comment.