"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const AppError_1 = __importDefault(require("../errors/AppError"));
const verifyAPIKey = (req, res, next) => {
    const authHeader = req.headers.authorization;
    if (!authHeader) {
        throw new AppError_1.default("ERR_SESSION_EXPIRED", 401);
    }
    const [, token] = authHeader.split(" ");
    const apiKeyIsValid = token === process.env.TOKEN_IAM_HORACIUS_EL;
    if (!apiKeyIsValid) {
        throw new AppError_1.default("Invalid token", 401);
    }
    return next();
};
exports.default = verifyAPIKey;
