API request timeout example

Use Node.js 22 or newer. No packages or account are needed.
From this folder, run:

node --test timeout.test.mjs

The test file starts the local server on an available port and stops it afterward.
There is no separate server startup command.

/slow waits 500 milliseconds before responding.
The first test uses a 50 millisecond client wait limit and expects TimeoutError.
/unavailable immediately returns HTTP 503 with a JSON error.
The second test checks that response, including its status and error value.

These are artificial teaching delays, not performance targets or measured service times.
The test covers cancellation before response headers. It does not demonstrate body-stream cancellation.
Cancelling a request does not prove a server operation was rolled back.
