// an external way to creating logs
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { apiHit } from "../../../globalUtils/apiHits.js";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import materialPerDayCheck from "../controller/materialsPerDay/materialPerDay.js";
import runTiImport from "../controller/notifications/tiIntergration.js";

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

app.openapi(
	createRoute({
		tags: ["notify"],
		summary: "Manually trigger TI intergrations.",
		method: "get",
		path: "/materialPerDayCheck",
		//middleware: authMiddleware,
		responses: responses(),
	}),
	async (c) => {
		apiHit(c, { endpoint: "/materialPerDayCheck" });
		const tiImport = await materialPerDayCheck();
		return c.json({
			success: tiImport?.success,
			message: tiImport?.message,
		});
	},
);
export default app;
