"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());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HotServer = exports.HotServerType = void 0;
const HotStaq_1 = require("./HotStaq");
/**
 * The type of server.
 */
var HotServerType;
(function (HotServerType) {
    HotServerType[HotServerType["HTTP"] = 0] = "HTTP";
    HotServerType[HotServerType["WebSockets"] = 1] = "WebSockets";
    HotServerType[HotServerType["Generate"] = 2] = "Generate";
    HotServerType[HotServerType["WebTesting"] = 3] = "WebTesting";
    HotServerType[HotServerType["APITesting"] = 4] = "APITesting";
})(HotServerType || (exports.HotServerType = HotServerType = {}));
/**
 * The server.
 */
class HotServer {
    constructor(processor) {
        if (processor instanceof HotStaq_1.HotStaq) {
            this.processor = processor;
            this.serverType = "Server";
            this.api = null;
            this.listenAddress = "0.0.0.0";
            this.ports = {
                http: 5000,
                https: 443
            };
            this.ssl = {
                cert: "",
                key: "",
                ca: ""
            };
            this.redirectHTTPtoHTTPS = true;
            this.type = HotServerType.HTTP;
            this.logger = processor.logger;
            this.secrets = {};
        }
        else {
            this.processor = processor.processor;
            this.serverType = processor.serverType || "Server";
            this.api = processor.api || null;
            this.listenAddress = processor.listenAddress || "0.0.0.0";
            this.ports = processor.ports || {
                http: 5000,
                https: 443
            };
            this.ssl = processor.ssl || {
                cert: "",
                key: "",
                ca: ""
            };
            this.redirectHTTPtoHTTPS = processor.redirectHTTPtoHTTPS != null ? processor.redirectHTTPtoHTTPS : true;
            this.type = processor.type || HotServerType.HTTP;
            this.logger = processor.logger;
            this.secrets = processor.secrets || {};
        }
    }
    /**
     * Set an API to this server. This will also set the associated
     * processor to this API as well.
     */
    setAPI(api) {
        return __awaiter(this, void 0, void 0, function* () {
            this.processor.api = api;
            this.api = api;
            //if (registerRoutes === true)
            //await this.api.registerRoutes ();
        });
    }
}
exports.HotServer = HotServer;
//# sourceMappingURL=HotServer.js.map