import {NextFunction, Request, Response} from "express";
import {AppError} from "../../core/AppError";

export const requireAdmin = (
    req: Request,
    _res: Response,
    next: NextFunction
) => {
    if (!req.auth || req.auth.type !== "admin") {
        throw new AppError("Forbidden", 403)
    }

    next()
}