Pages
Contents
API
init()
| await http.init(); |
Loads configuration and initializes the server.
start()
| http.start(); |
Starts the server (blocking).
stop()
| await http.stop(); |
Stops the server (graceful).
route(method, path, handler)
| http.route('GET', '/tool/:tool/:page?', (req, res) => { |
| res.send(`Tool: ${req.params.tool}`); |
| }); |
Supports URL parameters and optional segments with ?.
notFound(handler)
| http.notFound((req, res) => { |
| res.status(404).send('<h1>Not found</h1>'); |
| }); |
Sets a global 404 handler.
Events
http:requestβ request received (payload:{ traceId, method, path, params, query, headers, scheme, host, hostname, port, tld, contentType })http:responseβ response sent (payload:{ traceId, method, path, status, duration })http:responsealso includesmetricswhen available:{ uptime, memory, cpu }http:response:beforeβ before the response is sent (payload:{ req, res, status, headers, body })
Trace ID
Each request gets a traceId. It is attached to:
req.traceIdhttp:*eventsX-xPulse-Traceresponse header (when debug profiler is active)