57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
|
|
// routes
|
|
import manualLabelLog from "./routes/labeling/manualPrintLog.js";
|
|
import getPrinters from "./routes/printers/getPritners.js";
|
|
import { db } from "../../../database/dbclient.js";
|
|
import { settings } from "../../../database/schema/settings.js";
|
|
import updateprinters from "./routes/printers/updatePrinters.js";
|
|
import { updatePrinters } from "./controller/printers/updatePrinters.js";
|
|
import getLots from "./routes/lots/getLots.js";
|
|
import getLabels from "./routes/labeling/getLabels.js";
|
|
import { dycoConnect } from "./controller/specialProcesses/dyco/plcConnection.js";
|
|
import dycoCon from "./routes/specialProcesses/dyco/connection.js";
|
|
import dycoClose from "./routes/specialProcesses/dyco/closeConnection.js";
|
|
import manualprint from "./routes/labeling/manualPrint.js";
|
|
|
|
const app = new OpenAPIHono();
|
|
|
|
const routes = [
|
|
manualLabelLog,
|
|
//printer
|
|
getPrinters,
|
|
updateprinters,
|
|
// lots
|
|
getLots,
|
|
// labeling
|
|
getLabels,
|
|
manualprint,
|
|
//dyco
|
|
dycoCon,
|
|
dycoClose,
|
|
] as const;
|
|
const setting = await db.select().from(settings);
|
|
|
|
const appRoutes = routes.forEach((route) => {
|
|
app.route("/ocp", route);
|
|
});
|
|
|
|
app.all("/ocp/*", (c) => {
|
|
return c.json({
|
|
success: false,
|
|
message: "You have encounters a ocp route that dose not exist.",
|
|
});
|
|
});
|
|
|
|
// run the printer update on restart just to keep everything good
|
|
setTimeout(() => {
|
|
updatePrinters();
|
|
}, 3 * 1000);
|
|
|
|
// do the intnal connection to the dyco
|
|
setTimeout(() => {
|
|
dycoConnect();
|
|
}, 3 * 1000);
|
|
|
|
export default app;
|