feat(ocme): added in ocme service so we can utlize 2 ports
This commit is contained in:
@@ -6,12 +6,17 @@ import postRunningNr from "./route/postRunningNumber.js";
|
||||
import pickedup from "./route/pickedUp.js";
|
||||
import postsscc from "./route/postSSCC.js";
|
||||
import getShipments from "./route/getShipmentPallets.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";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const port = process.env.OCME_PORT;
|
||||
const routes = [getInfo, postRunningNr, postsscc, pickedup, getShipments] as const;
|
||||
const setting = await db.select().from(settings);
|
||||
|
||||
// app.route("/server", modules);
|
||||
const isActive = setting.filter((n) => n.name === "ocmeService");
|
||||
const appRoutes = routes.forEach((route) => {
|
||||
app.route("/api/v1", route);
|
||||
});
|
||||
@@ -19,5 +24,17 @@ const appRoutes = routes.forEach((route) => {
|
||||
app.all("/api/v1/*", (c) => {
|
||||
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;
|
||||
|
||||
@@ -2,7 +2,7 @@ import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
||||
import {getInfo} from "../controller/getInfo.js";
|
||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
const app = new OpenAPIHono({strict: false});
|
||||
|
||||
const AddSetting = z.object({
|
||||
name: z.string().openapi({example: "server"}),
|
||||
|
||||
Reference in New Issue
Block a user