Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions deno/index.js
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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) });
5 changes: 3 additions & 2 deletions deno/routes/index.js
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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;
13 changes: 13 additions & 0 deletions deno/routes/tts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Router } from "@oak/oak";
const ttsRouter = new Router();

ttsRouter.post("/", async (ctx) => {
const body = await ctx.request.body.value; // <-- важная строка!
ctx.response.body = {
ok: true,
received: body,
message: "vot-worker принимает POST /api/tts!"
};
});

export default ttsRouter;