Skip to content

fix(nestjs-trpc): Support the NodeAdapter from @nestjs/platform-node - #134

Merged
KevinEdry merged 3 commits into
mainfrom
fix/node-adapter-support
Nov 12, 2026
Merged

KevinEdry merged 3 commits into
mainfrom
fix/node-adapter-support

Conversation

@KevinEdry

Copy link
Copy Markdown
Owner

TRPCModule.forRoot() throws Unsupported http adapter: node on the NodeAdapter from @nestjs/platform-node (NestJS 12.4+), so tRPC can never initialize on that platform.

A new NodeDriver serves it through tRPC's native node-http adapter. It mounts a handler on the node router and passes the raw request and response to nodeHTTPRequestHandler, the same wiring a hand-rolled Node HTTP server uses. The node router strips the mount prefix connect-style, so the remaining pathname is the procedure path. The driver matches the router structurally, and the package takes no dependency on @nestjs/platform-node.

The adapter options union now hoists middleware out of the per-adapter variants and types it once against the native request. Each adapter spelled its own request type there, which made the union unusable by any one of them.

Two pre-existing fixes ride along in their own commits:

  • TRPCModuleOptions was imported as a value, which bun's native test runner rejects when loading two spec files.
  • The package build script still compiled a tsconfig that was deleted with the config/ directory, so bun run build always failed after the dist compile.

Verified against the packed tarball: queries and mutations answer on @nestjs/platform-node@12.4.2, and the Express and Fastify probes still pass.

Closes #133

Bun's native test runner enforces that value imports exist at runtime,
so importing the type-only TRPCModuleOptions as a value made it refuse
to load two spec files.
The config/ directory was removed in ed28eb8 but the build script kept
compiling config/tsconfig.json, so bun run build always failed after
the dist compile. Also syncs bun.lock with the NestJS 12 peer ranges
already in package.json.
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nestjs-trpc-docs Ready Ready Preview Nov 12, 2026 6:16pm UTC

Request Review

NodeAdapter.getType() returns 'node', which the platform dispatch
rejected. A dedicated NodeDriver now serves it through tRPC's native
node-http adapter, handing the router's raw req/res straight to
nodeHTTPRequestHandler - the same wiring a hand-rolled Node HTTP server
would use. The node router strips the mount prefix connect-style, so
the remaining pathname is the procedure path.

The adapter options union hoists middleware out of the per-adapter
variants and types it once against the native request: each adapter
spelled its own request type there, which made the union unusable by
any one of them.

Closes #133
@KevinEdry
KevinEdry force-pushed the fix/node-adapter-support branch from 766dc8e to c97ba40 Compare November 12, 2026 18:16
@KevinEdry
KevinEdry merged commit 7ab90d7 into main Nov 12, 2026
5 checks passed
@KevinEdry
KevinEdry deleted the fix/node-adapter-support branch November 12, 2026 19:08

This branch was successfully deployed

1 active deployment
Preview — c97ba406 Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support @nestjs/platform-node NodeAdapter

1 participant