Node.js
The Node adapter runs your REST API on the built-in node:httpserver. It's the default target for containers, VMs, and any Node-based PaaS (Heroku, Railway, Render, Fly.io). Use it when you control the process — long-lived, observable, and easy to debug.
When to choose Node
- You deploy to a container, VM, or Node PaaS (no per-request billing).
- You need
node:*modules (filesystem, child processes, native addons). - You want the broadest npm package compatibility.
Scaffold
The fastest way to start is the node-basic template. It ships with TypeScript, pnpm workspaces, a /healthzroute, graceful shutdown, and Hey API codegen wired up.
Install
Requires Node.js 24 LTS or newer. The adapter ships with @daloyjs/core; no extra dependency.
Minimal server
What the adapter wires for you
requestTimeout,headersTimeout, andkeepAliveTimeoutset to safe production values.- SIGTERM / SIGINT handlers that call
server.close()followed byserver.closeAllConnections()aftershutdownTimeoutMs— the pattern that became stable in Node 18.2 and is recommended on Node 24+. - When
trustProxy: true, the adapter readsx-forwarded-protoandx-forwarded-hostwhen constructing the request URL. Leave it off unless TLS is terminated at a known proxy you control.
Behind a load balancer
Two rules to avoid the classic 502/504 race:
- Make your load balancer's idle timeout greater than DaloyJS's
requestTimeoutMs. - Make DaloyJS's
keepAliveTimeoutgreaterthan the load balancer's — the Node adapter does this for you.
Dockerfile
Gotchas
- Don't put
process.exit()in a SIGTERM handler — letclose()drain. The adapter handles the hard kill after the timeout. - Set
hostname: "0.0.0.0"in containers; Node binds tolocalhostby default and that's invisible from outside the container.