"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiKeyMiddleware = void 0;
const env_1 = require("../../main/config/env");
const apiKeyMiddleware = (req, res, next) => {
    const providedKey = req.headers['x-api-key'];
    if (!env_1.env.ADMIN_API_KEY) {
        res.status(500).json({
            success: false,
            code: 'SERVER_CONFIGURATION_ERROR',
            message: 'Admin API key is not configured',
        });
        return;
    }
    if (providedKey !== env_1.env.ADMIN_API_KEY) {
        res.status(401).json({
            success: false,
            code: 'UNAUTHORIZED',
            message: 'Invalid or missing admin API key',
        });
        return;
    }
    next();
};
exports.apiKeyMiddleware = apiKeyMiddleware;
//# sourceMappingURL=api-key.middleware.js.map