Fundamentals
Platform agnosticism
Your code does not depend on a web server.
Your controllers, guards, pipes and services never touch a web-server library. They work with Kest's own small types (HttpRequest, HttpResponse). The actual server is an engine you plug in, so you can change the server (or run the same code somewhere else) without touching your application.
An engine implements one small interface, HttpAdapter: it turns its native request into an HttpRequest, calls the application, and writes the HttpResponse back.
| Package | Engine | Good for |
|---|---|---|
http-server-netty | Netty: epoll, kqueue or NIO, TLS, HTTP/2, graceful shutdown, @NonBlocking fast path | production |
http-server-jdk | the JDK's built-in server, one virtual thread per request, no extra dependencies | tests, small tools |
serverless | AWS Lambda / API Gateway events instead of a socket | functions (Serverless) |
app.http(NettyHttpAdapter(8080)) { ... } // production
app.http(JdkHttpAdapter(0)) { ... } // port 0 picks a free port: useful in testsBoth servers pass the same test suite. Beyond HTTP, the same handlers also run behind microservice transports, WebSocket gateways, GraphQL and gRPC, and the same guards, pipes and filters apply to all of them (Execution context).
Writing your own engine
Implement HttpAdapter.start(app): listen for requests, build an HttpRequest, call app.handle(request) (it is a suspend function that returns the HttpResponse), and write it. Look at the two bundled engines for the shape. Most applications never need this.
Why it matters
- Testing: use the JDK engine on a random port, with no network setup.
- Portability: the same application runs as a server, as a Lambda function, or behind another transport.
- Upgrades: a server library can be replaced without rewriting application code.