"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Config = exports.CanaryChecker = exports.Logs = exports.ConfigDB = exports.IncidentCommander = void 0;

var _axios = _interopRequireDefault(require("axios"));

var _toast = require("../components/Toast/toast");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var IncidentCommander = _axios.default.create({
  baseURL: "/db",
  headers: {
    Accept: "application/json",
    Prefer: "return=representation",
    "Content-Type": "application/json"
  }
});

exports.IncidentCommander = IncidentCommander;

var ConfigDB = _axios.default.create({
  baseURL: "/config/db",
  headers: {
    Accept: "application/json",
    Prefer: "return=representation",
    "Content-Type": "application/json"
  }
});

exports.ConfigDB = ConfigDB;

var Logs = _axios.default.create({
  baseURL: "/apm/search",
  headers: {
    Accept: "application/json",
    Prefer: "return=representation",
    "Content-Type": "application/json"
  }
});

exports.Logs = Logs;

var CanaryChecker = _axios.default.create({
  baseURL: "/canary",
  headers: {
    Accept: "application/json",
    Prefer: "return=representation",
    "Content-Type": "application/json"
  }
});

exports.CanaryChecker = CanaryChecker;

var Config = _axios.default.create({
  baseURL: "/config",
  headers: {
    Accept: "application/json",
    Prefer: "return=representation",
    "Content-Type": "application/json"
  }
});

exports.Config = Config;

for (var _i = 0, _arr = [IncidentCommander, Logs, CanaryChecker, Config, ConfigDB]; _i < _arr.length; _i++) {
  var client = _arr[_i];
  client.interceptors.response.use(function (response) {
    return response;
  }, function (error) {
    (0, _toast.toastError)(error.response.data.message);
    return Promise.reject(error);
  });
}