import { OpenAPIHono } from "@hono/zod-openapi";
import { qualityCycle } from "./controller/qualityCycle.js";
import request from "./route/getRequest.js";
import postReq from "./route/postNewRequest.js";

// pallet status data.
export const statusOptions = [
	{ name: "pending", uid: "1" },
	{ name: "moved", uid: "2" },
	{ name: "removed", uid: "3" },
	{ name: "reactivated", uid: "4" },
	{ name: "canceled", uid: "5" },
	{ name: "return", uid: "6" },
	{ name: "readyToReturn", uid: "7" },
];

const app = new OpenAPIHono();
const routes = [request, postReq] as const;

const appRoutes = routes.forEach((route) => {
	app.route("/quality", route);
});
app.all("/quality/*", (c) => {
	return c.json({
		success: false,
		message: "You have encounters a quality route that dose not exist.",
	});
});

/**
 * Initial and run the cycle up for checking the pallet moves for quality
 */
setTimeout(() => {
	qualityCycle();
}, 1000 * 5);

setInterval(() => {
	qualityCycle();
}, 1000 * 60);

export default app;
