refactor(ocme): corrections to endpoints to work with ocnme as intneeded
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {OpenAPIHono} from "@hono/zod-openapi";
|
||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||
|
||||
// routes
|
||||
import getInfo from "./route/getInfo.js";
|
||||
@@ -7,35 +7,52 @@ import pickedup from "./route/pickedUp.js";
|
||||
import postsscc from "./route/postSSCC.js";
|
||||
import getShipments from "./route/getShipmentPallets.js";
|
||||
import cycleCount from "./route/cycleCount.js";
|
||||
import {serve} from "@hono/node-server";
|
||||
import {createLog} from "../logger/logger.js";
|
||||
import {db} from "../../../database/dbclient.js";
|
||||
import {settings} from "../../../database/schema/settings.js";
|
||||
import { serve } from "@hono/node-server";
|
||||
import { createLog } from "../logger/logger.js";
|
||||
import { db } from "../../../database/dbclient.js";
|
||||
import { settings } from "../../../database/schema/settings.js";
|
||||
import manualTrigger from "./route/triggerCamera.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
const port = process.env.OCME_PORT;
|
||||
const routes = [getInfo, postRunningNr, postsscc, pickedup, getShipments, cycleCount] as const;
|
||||
const routes = [
|
||||
getInfo,
|
||||
postRunningNr,
|
||||
postsscc,
|
||||
pickedup,
|
||||
getShipments,
|
||||
cycleCount,
|
||||
manualTrigger,
|
||||
] as const;
|
||||
const setting = await db.select().from(settings);
|
||||
|
||||
const isActive = setting.filter((n) => n.name === "ocmeService");
|
||||
const appRoutes = routes.forEach((route) => {
|
||||
app.route("/api/v1", route);
|
||||
app.route("/api/v1", route);
|
||||
});
|
||||
|
||||
app.all("/api/v1/*", (c) => {
|
||||
return c.json({success: false, message: "you have encounted an ocme route that dose not exist."});
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "you have encounted an ocme route that dose not exist.",
|
||||
});
|
||||
});
|
||||
if (port && isActive[0]?.value === "1") {
|
||||
serve(
|
||||
{
|
||||
fetch: app.fetch,
|
||||
port: Number(port),
|
||||
hostname: "0.0.0.0",
|
||||
},
|
||||
(info) => {
|
||||
createLog("info", "LST", "server", `Ocme section is listening on http://${info.address}:${info.port}`);
|
||||
}
|
||||
);
|
||||
serve(
|
||||
{
|
||||
fetch: app.fetch,
|
||||
port: Number(port),
|
||||
hostname: "0.0.0.0",
|
||||
},
|
||||
(info) => {
|
||||
createLog(
|
||||
"info",
|
||||
"LST",
|
||||
"server",
|
||||
`Ocme section is listening on http://${info.address}:${info.port}`
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user