aboutsummaryrefslogtreecommitdiffhomepage
path: root/worker/index.mjs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-05 20:12:41 +0900
committernsfisis <nsfisis@gmail.com>2025-09-05 20:52:56 +0900
commitc7941d027be068f6e563a17e882232580fe15334 (patch)
tree40479fdff8903af289f8a2a02c6f58ba1c69a82c /worker/index.mjs
parent0f91e938442b22e54ba2f1b29e25d678cf0acdd3 (diff)
downloadiosdc-japan-2025-albatross-c7941d027be068f6e563a17e882232580fe15334.tar.gz
iosdc-japan-2025-albatross-c7941d027be068f6e563a17e882232580fe15334.tar.zst
iosdc-japan-2025-albatross-c7941d027be068f6e563a17e882232580fe15334.zip
feat(worker): move directory worker/ to worker/php/
Diffstat (limited to 'worker/index.mjs')
-rw-r--r--worker/index.mjs39
1 files changed, 0 insertions, 39 deletions
diff --git a/worker/index.mjs b/worker/index.mjs
deleted file mode 100644
index 9950ffa..0000000
--- a/worker/index.mjs
+++ /dev/null
@@ -1,39 +0,0 @@
-import { fork } from "node:child_process";
-import { serve } from "@hono/node-server";
-import { Hono } from "hono";
-
-const execPhp = (code, input, timeoutMsec) => {
- return new Promise((resolve, _reject) => {
- const proc = fork("./exec.mjs");
-
- proc.send({ code, input });
-
- proc.on("message", (result) => {
- resolve(result);
- proc.kill();
- });
-
- setTimeout(() => {
- resolve({
- status: "timeout",
- stdout: "",
- stderr: `Time Limit Exceeded: ${timeoutMsec} msec`,
- });
- proc.kill();
- }, timeoutMsec);
- });
-};
-
-const app = new Hono();
-
-app.post("/exec", async (c) => {
- console.log("worker/exec");
- const { code, stdin, max_duration_ms } = await c.req.json();
- const result = await execPhp(code, stdin, max_duration_ms);
- return c.json(result);
-});
-
-serve({
- fetch: app.fetch,
- port: 80,
-});