feat(ocp): printer cycling backend and frontend done :)
This commit is contained in:
41
server/services/ocp/routes/printers/startCycle.ts
Normal file
41
server/services/ocp/routes/printers/startCycle.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// an external way to creating logs
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { printerCycle } from "../../controller/printers/printerCycle.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp:printers"],
|
||||
summary: "starts the printers cycling.",
|
||||
method: "get",
|
||||
path: "/startsprintercycle",
|
||||
middleware: authMiddleware,
|
||||
//description: "This might be a temp soltuin during the transtion between versions",
|
||||
// request: {
|
||||
// body: {content: {"application/json": {schema: CreateLog}}},
|
||||
// },
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
const { data, error } = await tryCatch(printerCycle());
|
||||
const dataError: any = error;
|
||||
if (error) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "Error in stopping the printer cycle",
|
||||
data: dataError?.data,
|
||||
});
|
||||
}
|
||||
const getData: any = data;
|
||||
return c.json({
|
||||
success: getData?.success,
|
||||
message: getData?.message,
|
||||
data: getData.data ?? [],
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
41
server/services/ocp/routes/printers/stopCycle.ts
Normal file
41
server/services/ocp/routes/printers/stopCycle.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
// an external way to creating logs
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { stopPrinterCycle } from "../../controller/printers/printerCycle.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp:printers"],
|
||||
summary: "Stops the printers cycling.",
|
||||
method: "get",
|
||||
path: "/stopprintercycle",
|
||||
middleware: authMiddleware,
|
||||
//description: "This might be a temp soltuin during the transtion between versions",
|
||||
// request: {
|
||||
// body: {content: {"application/json": {schema: CreateLog}}},
|
||||
// },
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
const { data, error } = await tryCatch(stopPrinterCycle());
|
||||
const dataError: any = error;
|
||||
if (error) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "Error in stopping the printer cycle",
|
||||
data: dataError?.data,
|
||||
});
|
||||
}
|
||||
const getData: any = data;
|
||||
return c.json({
|
||||
success: getData?.success,
|
||||
message: getData?.message,
|
||||
data: getData.data ?? [],
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user