@@ -146,7 +146,7 @@ In oRPC middleware is very useful and fully typed you can find more info [here](
146146## Start Your Server
147147
148148` ` ` ts twoslash
149- import { ORPCHandler , CompositeHandler } from ' @orpc/server/node'
149+ import { ORPCHandler } from ' @orpc/server/node'
150150import { OpenAPIServerlessHandler } from ' @orpc/openapi/node'
151151import { createServer } from ' node:http'
152152import { router } from ' examples/server'
@@ -157,15 +157,30 @@ const openapiHandler = new OpenAPIServerlessHandler(router, {
157157 new ZodCoercer (),
158158 ],
159159})
160+
160161const orpcHandler = new ORPCHandler (router )
161- const compositeHandler = new CompositeHandler ([openapiHandler , orpcHandler ])
162162
163163const server = createServer (async (req , res ) => {
164164 if (req .url ?.startsWith (' /api' )) {
165- return compositeHandler .handle (req , res , {
165+ const { matched } = await openapiHandler .handle (req , res , {
166166 prefix: ' /api' ,
167167 context: {},
168168 })
169+
170+ if (matched ){
171+ return
172+ }
173+ }
174+
175+ if (req .url ?.startsWith (' /rpc' )){
176+ const { matched } = await orpcHandler .handle (req , res , {
177+ prefix: ' /rpc' ,
178+ context: {},
179+ })
180+
181+ if (matched ){
182+ return
183+ }
169184 }
170185
171186 res .statusCode = 404
@@ -190,7 +205,7 @@ import { ORPCLink } from '@orpc/client/fetch'
190205import type { router } from ' examples/server'
191206
192207const orpcLink = new ORPCLink ({
193- url: ' http://localhost:3000/api ' ,
208+ url: ' http://localhost:3000/rpc ' ,
194209 // fetch: optional override for the default fetch function
195210 // headers: provide additional headers
196211})
0 commit comments