text: "use strict";
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
      function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
      return new (P || (P = Promise))(function (resolve, reject) {
          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
          function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
          step((generator = generator.apply(thisArg, _arguments || [])).next());
      });
  };
  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 config_1 = __importDefault(require("config"));
  const path_1 = __importDefault(require("path"));
  const mongoose_1 = __importDefault(require("mongoose"));
  const app = express_1.default();
  const a = { extended: true };
  app.use(express_1.default.json(a));
  if (process.env.NODE_ENV === 'production') {
      app.use('/', express_1.default.static(path_1.default.join(__dirname, 'client', 'build')));
      app.get('*', (req, res) => {
          res.sendFile(path_1.default.resolve(__dirname, 'client', 'build', 'index.html'));
      });
  }
  const PORT = config_1.default.get('port') || 5000;
  const MONGOURI = config_1.default.get('mongoUri');
  function start() {
      return __awaiter(this, void 0, void 0, function* () {
          try {
              yield mongoose_1.default.connect(MONGOURI, {
                  useNewUrlParser: true,
                  useUnifiedTopology: true,
                  useCreateIndex: true
              });
          }
          catch (e) {
              console.log('Server Error', e.message);
              process.exit(1);
          }
          app.listen(PORT, () => {
              console.log(`App has been started on port ${PORT}...`);
          });
      });
  }
  start();
  