// an external way to creating logs
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { apiHit } from "../../../globalUtils/apiHits.js";
import { prodUser } from "../controller/produser.js";
import { getProdRoles } from "../controller/getprodRoles.js";

const app = new OpenAPIHono({ strict: false });

app.openapi(
    createRoute({
        tags: ["admin"],
        summary: "Returns the current prod roles",
        method: "get",
        path: "/prodrole",
        responses: responses(),
    }),
    async (c) => {
        const { data, error } = await tryCatch(getProdRoles());
        apiHit(c, { endpoint: "/prodrole" });
        if (error) {
            return c.json({
                success: false,
                message: "Error getting new role.",
            });
        }

        return c.json({
            success: data.success,
            message: data.message,
            data: data.data,
        });
    }
);
export default app;
