"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const health_json_1 = __importDefault(require("../schemas/health.json"));
const health = (app, opts, done) => {
    async function checkRedis() {
        try {
            await app.redis.ping();
            return true;
        }
        catch (e) {
            return false;
        }
    }
    app.get("/", {
        schema: {
            response: {
                200: health_json_1.default,
            },
            tags: ["Admin"],
            summary: "Check availability"
        },
    }, async (request, reply) => {
        const redis = await checkRedis();
        reply.status(redis ? 200 : 502);
        reply.send({
            redis: redis ? "up" : "down",
        });
    });
    done();
};
exports.default = health;
//# sourceMappingURL=health.js.map