"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = __importDefault(require("config"));
const express_1 = __importDefault(require("express"));
const BaseService_1 = __importDefault(require("../common/BaseService"));
const Logger_1 = __importStar(require("../common/Logger"));
const path_1 = __importDefault(require("path"));
class HttpHostingService extends BaseService_1.default {
    constructor() {
        super(Logger_1.Category.HttpHostingService);
        this.app = (0, express_1.default)();
        if (!this.enabled) {
            this.logger.warn('Service is not enabled. Exit now...');
            return;
        }
        this.app.use(Logger_1.default.getExpressLogger(Logger_1.Category.HttpHostingService));
        const staticPath = path_1.default.resolve(process.env.NODE_CONFIG_DIR, config_1.default.get('http_hosting_service.static_path'));
        this.app.use(express_1.default.static(staticPath));
    }
    start() {
        const bind = config_1.default.get('http_hosting_service.bind');
        const port = config_1.default.get('http_hosting_service.port');
        this.app.listen(port, bind, () => {
            this.logger.info(`Started listening at http://${bind}:${port}`);
        });
    }
}
exports.default = HttpHostingService;
//# sourceMappingURL=HttpHostingService.js.map