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.VITE_SERVER_PORT
|
||||||
: process.env.PROD_PORT;
|
: process.env.PROD_PORT;
|
||||||
|
|
||||||
|
const ocmeport = process.env.OCME_PORT;
|
||||||
serve(
|
serve(
|
||||||
{
|
{
|
||||||
fetch: app.fetch,
|
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;
|
export type AppRoutes = typeof appRoutes;
|
||||||
|
|||||||
@@ -16,43 +16,24 @@ import manualTrigger from "./route/triggerCamera.js";
|
|||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
const port = process.env.OCME_PORT;
|
const port = process.env.OCME_PORT;
|
||||||
const routes = [
|
const routes = [
|
||||||
getInfo,
|
getInfo,
|
||||||
postRunningNr,
|
postRunningNr,
|
||||||
postsscc,
|
postsscc,
|
||||||
pickedup,
|
pickedup,
|
||||||
getShipments,
|
getShipments,
|
||||||
cycleCount,
|
cycleCount,
|
||||||
manualTrigger,
|
manualTrigger,
|
||||||
] as const;
|
] as const;
|
||||||
const setting = await db.select().from(settings);
|
|
||||||
|
|
||||||
const isActive = setting.filter((n) => n.name === "ocmeService");
|
|
||||||
const appRoutes = routes.forEach((route) => {
|
const appRoutes = routes.forEach((route) => {
|
||||||
app.route("/api/v1", route);
|
app.route("/api/v1", route);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.all("/api/v1/*", (c) => {
|
app.all("/api/v1/*", (c) => {
|
||||||
return c.json({
|
return c.json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "you have encounted an ocme route that dose not exist.",
|
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;
|
export default app;
|
||||||
|
|||||||
Reference in New Issue
Block a user