From 363ceac6a10f6e51ce1007700edc03ae4ad78ae0 Mon Sep 17 00:00:00 2001 From: Pavel Dumbrao Date: Thu, 7 Aug 2025 16:28:23 +0300 Subject: [PATCH 1/4] index.js --- deno/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/deno/index.js b/deno/index.js index 12c28a7..61718ed 100644 --- a/deno/index.js +++ b/deno/index.js @@ -1,6 +1,5 @@ import { Application, Status } from "@oak/oak"; - -import { corsHeaders, host, port } from "./config.js"; +import { corsHeaders } from "./config.js"; // удаляем host, port из импорта import mainRouter from "./routes/index.js"; const app = new Application(); @@ -10,16 +9,17 @@ app.use(async (ctx, next) => { for (const corsHeaderKey of Object.keys(corsHeaders)) { ctx.response.headers.set(corsHeaderKey, corsHeaders[corsHeaderKey]); } - if (ctx.request.method === "OPTIONS") { ctx.response.status = Status.NoContent; return; } - await next(); }); app.use(mainRouter.routes()); -console.log(`🐿️ Oak is running at ${host}:${port}`); -await app.listen({ host, port }); +// Главная фишка — получение порта из ENV: +const PORT = Deno.env.get("PORT") || "8080"; +// Можно явно указать, что слушаем на всех интерфейсах: +console.log(`🐿️ Oak is running at 0.0.0.0:${PORT}`); +await app.listen({ hostname: "0.0.0.0", port: Number(PORT) }); From 940372f22f1325327be7d0af606ab0be14656c93 Mon Sep 17 00:00:00 2001 From: Pavel Dumbrao Date: Thu, 7 Aug 2025 17:05:38 +0300 Subject: [PATCH 2/4] Create tts.js --- deno/routes/tts.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 deno/routes/tts.js diff --git a/deno/routes/tts.js b/deno/routes/tts.js new file mode 100644 index 0000000..d2abed5 --- /dev/null +++ b/deno/routes/tts.js @@ -0,0 +1,13 @@ +import { Router } from "@oak/oak"; +const ttsRouter = new Router(); + +ttsRouter.post("/", async (ctx) => { + const body = await ctx.request.body({ type: "json" }).value; + ctx.response.body = { + ok: true, + received: body, + message: "vot-worker принимает POST /api/tts!" + }; +}); + +export default ttsRouter; From 1dcdb580ce20429f60d15ce6de387988b5e87a99 Mon Sep 17 00:00:00 2001 From: Pavel Dumbrao Date: Thu, 7 Aug 2025 17:06:47 +0300 Subject: [PATCH 3/4] Update index.js --- deno/routes/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deno/routes/index.js b/deno/routes/index.js index 4407ecb..aaaf6b8 100644 --- a/deno/routes/index.js +++ b/deno/routes/index.js @@ -1,10 +1,10 @@ import { Router } from "@oak/oak"; - import videoTranslationRouter from "./videoTranslation.js"; import videoSubtitlesRouter from "./videoSubtitles.js"; import streamTranslationRouter from "./streamTranslation.js"; import sessionRouter from "./session.js"; import healthRouter from "./health.js"; +import ttsRouter from "./tts.js"; const mainRouter = new Router() .use( @@ -23,6 +23,7 @@ const mainRouter = new Router() streamTranslationRouter.allowedMethods() ) .use("/session", sessionRouter.routes(), sessionRouter.allowedMethods()) - .use("/health", healthRouter.routes(), healthRouter.allowedMethods()); + .use("/health", healthRouter.routes(), healthRouter.allowedMethods()) + .use("/api/tts", ttsRouter.routes(), ttsRouter.allowedMethods()); export default mainRouter; From 7aec3000a6c21591f4b41de38611facce2cbb57b Mon Sep 17 00:00:00 2001 From: Pavel Dumbrao Date: Thu, 7 Aug 2025 17:14:56 +0300 Subject: [PATCH 4/4] Update tts.js --- deno/routes/tts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno/routes/tts.js b/deno/routes/tts.js index d2abed5..4b33899 100644 --- a/deno/routes/tts.js +++ b/deno/routes/tts.js @@ -2,7 +2,7 @@ import { Router } from "@oak/oak"; const ttsRouter = new Router(); ttsRouter.post("/", async (ctx) => { - const body = await ctx.request.body({ type: "json" }).value; + const body = await ctx.request.body.value; // <-- важная строка! ctx.response.body = { ok: true, received: body,