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";
import { triggerScanner } from "../controller/triggerCamera.js";

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

app.openapi(
    createRoute({
        tags: ["ocme"],
        summary: "Triggers the camera at the end of the dyco.",
        method: "get",
        path: "/manualCameraTrigger",
        responses: responses(),
    }),
    async (c) => {
        // make sure we have a vaid user being accessed thats really logged in
        apiHit(c, { endpoint: "/manualCameraTrigger" });
        const manualTrigger: any = await triggerScanner();
        console.log(manualTrigger);
        return c.json({
            success: manualTrigger.success,
            message: manualTrigger.message,
        });
    }
);
export default app;
