MCPcopy Create free account
hub / github.com/DemonMartin/tlsClient / startServer

Function startServer

tests/test.simple_request.ts:9–21  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7const url = `http://127.0.0.1:${PORT}`;
8
9function startServer(): Promise<Server> {
10 return new Promise((resolve, reject) => {
11 const server = createServer((_, res) => {
12 // Default HTTP/1.1 keep-alive — do NOT send Connection: close here; that would
13 // force a new TCP connection per request and tank req/s. Shutdown uses
14 // closeAllConnections() instead.
15 res.writeHead(200, { 'Content-Type': 'text/plain' });
16 res.end('ok');
17 });
18 server.listen(PORT, '127.0.0.1', () => resolve(server));
19 server.on('error', reject);
20 });
21}
22
23/** Stops accepting connections, tears down open sockets, then resolves when the server is fully closed. */
24function stopServer(server: Server): Promise<void> {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected