Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 691 Bytes

File metadata and controls

36 lines (29 loc) · 691 Bytes
title Bun
toc false
breadcrumbs false

Language: JavaScript · View source on GitHub

Dockerfile

FROM oven/bun:1-slim
WORKDIR /app
COPY src/Servers/BunServer/server.ts .
ENTRYPOINT ["bun", "run", "server.ts", "8080"]

Source — server.ts

const port = parseInt(Bun.argv[2] || "8080", 10);

Bun.serve({
  port,
  hostname: "0.0.0.0",
  async fetch(req) {
    if (req.method === "POST") {
      const body = await req.text();
      return new Response(body);
    }
    return new Response("OK");
  },
});

console.log(`Bun listening on 127.0.0.1:${port}`);