| 1 | // Runs as an external Service program: `node /app/echo-server.ts`. |
| 2 | // Node strips the types, so only erasable TypeScript syntax is allowed here. |
| 3 | import * as http from "node:http"; |
| 4 | |
| 5 | const ECHO_BODY = process.env.ECHO_BODY ?? "fly-echo"; |
| 6 | |
| 7 | const port = Number(process.env.PORT ?? 3000); |
| 8 | |
| 9 | http |
| 10 | .createServer((_request, response: http.ServerResponse) => { |
| 11 | response.writeHead(200, { "content-type": "text/plain" }); |
| 12 | response.end(ECHO_BODY); |
| 13 | }) |
| 14 | .listen(port, "0.0.0.0"); |