klain:http — handler-returns-response server
Node's http.createServer is also implemented (under the http name), but klain:http is this project's own model: listen(port, req ⇒ response), where the handler simply returns a typed { status, body, headers } object. Same runtime, explicitly non-Node shape.
import http from 'klain:http'
interface Res { status: number; body: string; headers: Map<string, string> }
http.listen(8080, (req: HttpRequest): Res => {
return { status: 200, body: 'hello ' + req.path, headers: new Map() }
}) The server transparently accepts cleartext HTTP/2 (h2c) alongside HTTP/1.1 on the same port, and the handler's return type is checked at compile time. Reach for the Node-shaped http.createServer when you want the streaming res API; reach for klain:http when a pure request→response function is all you need.