feat(ocp): added in printers get and add
This commit is contained in:
50
server/services/ocp/routes/printers/getPritners.ts
Normal file
50
server/services/ocp/routes/printers/getPritners.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
// an external way to creating logs
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { getPrinters } from "../../controller/getPrinters.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
const CreateLog = z.object({
|
||||
line: z.string().openapi({ example: "info" }),
|
||||
initials: z.string().openapi({ example: "server" }),
|
||||
printReason: z.string().openapi({ example: "This is a new log posted" }),
|
||||
additionalComments: z
|
||||
.string()
|
||||
.optional()
|
||||
.openapi({ example: "Some reason why we did this." }),
|
||||
});
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp"],
|
||||
summary: "Prints a label.",
|
||||
method: "get",
|
||||
path: "/getprinters",
|
||||
//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: printData, error: printError } = await tryCatch(
|
||||
getPrinters()
|
||||
);
|
||||
|
||||
if (printError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "There was an error getting the printers",
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: printData.success,
|
||||
message: printData.message,
|
||||
data: printData.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
51
server/services/ocp/routes/printers/updatePrinters.ts
Normal file
51
server/services/ocp/routes/printers/updatePrinters.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// an external way to creating logs
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { getPrinters } from "../../controller/getPrinters.js";
|
||||
import { updatePrinters } from "../../controller/updatePrinters.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
const CreateLog = z.object({
|
||||
line: z.string().openapi({ example: "info" }),
|
||||
initials: z.string().openapi({ example: "server" }),
|
||||
printReason: z.string().openapi({ example: "This is a new log posted" }),
|
||||
additionalComments: z
|
||||
.string()
|
||||
.optional()
|
||||
.openapi({ example: "Some reason why we did this." }),
|
||||
});
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp"],
|
||||
summary: "Prints a label.",
|
||||
method: "get",
|
||||
path: "/updateprinters",
|
||||
//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: printData, error: printError } = await tryCatch(
|
||||
updatePrinters()
|
||||
);
|
||||
|
||||
if (printError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "There was an error getting the printers",
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: printData.success,
|
||||
message: printData.message,
|
||||
data: printData.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user