text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const express_1 = __importDefault(require("express"));
  const mongoose_1 = __importDefault(require("mongoose"));
  const cors_1 = __importDefault(require("cors"));
  const helmet_1 = __importDefault(require("helmet"));
  const cleanBookings_1 = __importDefault(require("./util/cleanBookings"));
  const cleanFailedFlights_1 = __importDefault(require("./util/cleanFailedFlights"));
  const fs_1 = __importDefault(require("fs"));
  const path_1 = __importDefault(require("path"));
  const https_1 = __importDefault(require("https"));
  const repairPlanes_1 = __importDefault(require("./util/repairPlanes"));
  const cleanTasks_1 = __importDefault(require("./util/cleanTasks"));
  const logger_1 = __importDefault(require("./util/logger"));
  const freeRoutes_1 = __importDefault(require("./routes/freeRoutes"));
  const safeRoutes_1 = __importDefault(require("./routes/safeRoutes"));
  const package_json_1 = require("./package.json");
  const config_json_1 = require("./config.json");
  let app = express_1.default();
  app.use(express_1.default.json());
  app.use(cors_1.default());
  app.use(helmet_1.default());
  app.use('/api', safeRoutes_1.default);
  app.use('/', freeRoutes_1.default);
  mongoose_1.default.connect(config_json_1.mongoCfg.uri, {
      useNewUrlParser: true,
      useUnifiedTopology: true,
      useFindAndModify: false
  });
  //Default execution process;
  cleanBookings_1.default();
  cleanFailedFlights_1.default();
  repairPlanes_1.default();
  cleanTasks_1.default();
  setInterval(() => cleanBookings_1.default(), 1000 * 60);
  setInterval(() => cleanFailedFlights_1.default(), 1000 * 60);
  setInterval(() => cleanTasks_1.default(), 1000 * 60);
  setInterval(() => repairPlanes_1.default(), 1000 * 60 * 60);
  logger_1.default.info(`vEuroExpress API v${package_json_1.version}.`);
  logger_1.default.info(`Initialising API endpoints...`);
  https_1.default.globalAgent.options.ca = require('ssl-root-cas').create();
  process.on('uncaughtException', (err) => logger_1.default.error(err));
  process.on('unhandledRejection', (err) => logger_1.default.error(err));
  https_1.default.createServer({
      key: fs_1.default.readFileSync(path_1.default.join(__dirname, 'cert', 'key.key')),
      cert: fs_1.default.readFileSync(path_1.default.join(__dirname, 'cert', 'cert.pem')),
  }, app).listen(2083, () => logger_1.default.info('Initialisation complete. vEX API running on port 2083...'));
  