import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { getInfo } from "../controller/getInfo.js";
import { apiHit } from "../../../globalUtils/apiHits.js";
import { responses } from "../../../globalUtils/routeDefs/responses.js";

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

app.openapi(
    createRoute({
        tags: ["ocme"],
        summary: "Get all current info",
        method: "get",
        path: "/getInfo",

        responses: responses(),
    }),
    async (c) => {
        // make sure we have a vaid user being accessed thats really logged in
        apiHit(c, { endpoint: "/getInfo" });
        try {
            return c.json(
                { success: true, message: "Ocme Info", data: await getInfo() },
                200
            );
        } catch (error) {
            return c.json(
                {
                    success: false,
                    message: "There was an error getting ocmeInfo data",
                    data: error,
                },
                400
            );
        }
    }
);
export default app;
