Skip to content
File

Blob: src/workerd/api/node/tests/http-server-nodejs-server.js

javascript21 lines
1// Copyright (c) 2017-2022 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5// This is a sidecar that runs alongside the http-client-nodejs-test.* tests.
6// It is executed using the appropriate Node.js version defined in build/deps/nodejs.MODULE.bazel.
7const http = require('node:http');
8 
9function reportPort(server) {
10 console.info(`Listening on port ${server.address().port}`);
11}
12 
13const pongServer = http.createServer((req, res) => {
14 req.resume();
15 req.on('end', () => {
16 res.writeHead(200);
17 res.end('pong');
18 });
19});
20pongServer.listen(process.env.PONG_SERVER_PORT, () => reportPort(pongServer));