refactor(ocme): moved the server port to the app vs ocme
This commit is contained in:
@@ -189,6 +189,7 @@ const port =
|
||||
? process.env.VITE_SERVER_PORT
|
||||
: process.env.PROD_PORT;
|
||||
|
||||
const ocmeport = process.env.OCME_PORT;
|
||||
serve(
|
||||
{
|
||||
fetch: app.fetch,
|
||||
@@ -205,4 +206,27 @@ serve(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Only for ocme until we get them switched over to the single port setup.
|
||||
*/
|
||||
const setting = await db.select().from(settings);
|
||||
const isActive = setting.filter((n) => n.name === "ocmeService");
|
||||
if (ocmeport && isActive[0]?.value === "1") {
|
||||
serve(
|
||||
{
|
||||
fetch: app.fetch,
|
||||
port: Number(ocmeport),
|
||||
hostname: "0.0.0.0",
|
||||
},
|
||||
(info) => {
|
||||
createLog(
|
||||
"info",
|
||||
"LST",
|
||||
"server",
|
||||
`Ocme section is listening on http://${info.address}:${info.port}`
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export type AppRoutes = typeof appRoutes;
|
||||
|
||||
@@ -16,43 +16,24 @@ import manualTrigger from "./route/triggerCamera.js";
|
||||
const app = new OpenAPIHono();
|
||||
const port = process.env.OCME_PORT;
|
||||
const routes = [
|
||||
getInfo,
|
||||
postRunningNr,
|
||||
postsscc,
|
||||
pickedup,
|
||||
getShipments,
|
||||
cycleCount,
|
||||
manualTrigger,
|
||||
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}`
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user