"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.startHttpsServer = startHttpsServer;

var _https = _interopRequireDefault(require("https"));

var _logger = require("../../logger");

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

function startHttpsServer(app, options) {
  const {
    httpsOptions,
    serverExtras
  } = options;
  const {
    httpsPort,
    httpsUrl
  } = serverExtras;

  if (!httpsOptions) {
    return null;
  }

  const httpsServer = _https.default.createServer(httpsOptions, app);

  httpsServer.listen(httpsPort, err => {
    if (err) {
      throw err;
    }

    (0, _logger.messageLogger)(`Listening at ${httpsUrl}`);
  });
  return httpsServer;
}