feat(ocme): added in ocme with endpoints base

This commit is contained in:
2025-03-07 13:39:32 -06:00
parent a1c9ad65b8
commit ef26b6aa79
11 changed files with 1596 additions and 15 deletions

View File

@@ -1,19 +1,19 @@
import type {Context} from "hono";
import {OpenAPIHono} from "@hono/zod-openapi";
export const ocmeService = async (c: Context) => {
const url = new URL(c.req.url);
// routes
import getInfo from "./route/getInfo.js";
import postRunningNr from "./route/postRunningNumber.js";
const app = new OpenAPIHono();
const ocmeUrl = `http://localhost:${process.env.OCME_PORT}${url.pathname.replace("/ocme", "")}`;
const routes = [getInfo, postRunningNr] as const;
console.log(ocmeUrl);
const ocmeResponse = await fetch(ocmeUrl, {
method: c.req.method,
headers: c.req.raw.headers,
body: c.req.method !== "GET" && c.req.method !== "HEAD" ? await c.req.text() : undefined,
});
// app.route("/server", modules);
const appRoutes = routes.forEach((route) => {
app.route("/api/v1", route);
});
return new Response(ocmeResponse.body, {
status: ocmeResponse.status,
headers: ocmeResponse.headers,
});
};
app.all("/api/v1/*", (c) => {
return c.json({success: false, message: "you have encounted an ocme route that dose not exist."});
});
export default app;