"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "MetricsController", {
    enumerable: true,
    get: function() {
        return MetricsController;
    }
});
const _awilixexpress = require("awilix-express");
const _promclient = require("prom-client");
const _express = require("express");
const _configservice = require("../services/core/config.service");
const _serverconstants = require("../server.constants");
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
class MetricsController {
    configService;
    constructor(configService){
        this.configService = configService;
    }
    async getMetrics(req, res) {
        if (this.configService.get(_serverconstants.AppConstants.ENABLE_PROMETHEUS_METRICS) !== "true") {
            return res.status(404).send("Metrics disabled");
        }
        res.setHeader("Content-Type", _promclient.register.contentType);
        res.end(await _promclient.register.metrics());
    }
}
_ts_decorate([
    (0, _awilixexpress.GET)(),
    (0, _awilixexpress.route)(""),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", [
        typeof _express.Request === "undefined" ? Object : _express.Request,
        typeof _express.Response === "undefined" ? Object : _express.Response
    ]),
    _ts_metadata("design:returntype", Promise)
], MetricsController.prototype, "getMetrics", null);
MetricsController = _ts_decorate([
    (0, _awilixexpress.route)("/metrics"),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", [
        typeof _configservice.IConfigService === "undefined" ? Object : _configservice.IConfigService
    ])
], MetricsController);

//# sourceMappingURL=metrics.controller.js.map