trpc-bun-adapter
trpc-bun-adapter copied to clipboard
Please share an example of code
Hello sir, could you please explain, how to use this library?
I wrote this code, and it's working:
import index from "./index.html";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
Bun.serve({
routes: {
"/trpc/*": async (req) => {
return fetchRequestHandler({
createContext: () => ({}) as never,
req: req,
endpoint: '/trpc',
router: router
})
},
"/*": index,
},
})
Now how to use this library?
const indexHandler = createBunHttpHandler({
router,
// optional arguments:
endpoint: '/trpc',
onError: console.error,
batching: {
enabled: true,
},
emitWsUpgrades: false, // pass true to upgrade to WebSocket
});
routes: {
"/trpc/*": () => indexHandler ??????