"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initSyntheticsServer = void 0; var _tls_rule = require("./alert_rules/tls_rule/tls_rule"); var _monitor_status_rule = require("./alert_rules/status_rule/monitor_status_rule"); var _create_route_with_auth = require("./routes/create_route_with_auth"); var _synthetics_route_wrapper = require("./synthetics_route_wrapper"); var _routes = require("./routes"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ const initSyntheticsServer = (server, syntheticsMonitorClient, plugins, ruleDataClient) => { _routes.syntheticsAppRestApiRoutes.forEach(route => { const { method, options, handler, validate, path } = (0, _synthetics_route_wrapper.syntheticsRouteWrapper)((0, _create_route_with_auth.createSyntheticsRouteWithAuth)(route), server, syntheticsMonitorClient); const routeDefinition = { path, validate, options }; switch (method) { case 'GET': server.router.get(routeDefinition, handler); break; case 'POST': server.router.post(routeDefinition, handler); break; case 'PUT': server.router.put(routeDefinition, handler); break; case 'DELETE': server.router.delete(routeDefinition, handler); break; default: throw new Error(`Handler for method ${method} is not defined`); } }); const { alerting: { registerType } } = plugins; const statusAlert = (0, _monitor_status_rule.registerSyntheticsStatusCheckRule)(server, plugins, syntheticsMonitorClient, ruleDataClient); registerType(statusAlert); const tlsRule = (0, _tls_rule.registerSyntheticsTLSCheckRule)(server, plugins, syntheticsMonitorClient, ruleDataClient); registerType(tlsRule); }; exports.initSyntheticsServer = initSyntheticsServer;