H
Hono•2mo ago
codeauthor

Hono RPC

Hello 👋 techies! It's Alfred. I'm currently working on building a backend service with Bun and Hono. I'm facing some challenges with the Hono RPC. Can anyone help me out?
19 Replies
coleretriever
coleretriever•2mo ago
describe the issue here, this is what the help threads are for
codeauthor
codeauthorOP•2mo ago
Hey Coleretriever, I finally figured out why I wasn't getting auto-complete in my Hobo RPC project. It turns out that breaking the app into modules was causing the issue. I tried using the createFactory method as suggested in the docs, but it wasn't working. Luckily, I was able to resolve it by manually defining the types.
coleretriever
coleretriever•2mo ago
did you use createFactory and middleware vs creating endpoints? I've run into the same issue generating an OpenAPI client
codeauthor
codeauthorOP•2mo ago
No, it didn't fix it. I passed the route definition when initializing Hono.
type RouteSchema = {} // define the path to endpoint here

const app = new Hono<{}, RouteSchema, "/">()
type RouteSchema = {} // define the path to endpoint here

const app = new Hono<{}, RouteSchema, "/">()
Steven-sensei
Steven-sensei•2mo ago
I think it's because you are doing something bad in your code base i use hono rpc and has no issue with type completion and didn't need to do that
codeauthor
codeauthorOP•2mo ago
It's difficult to say. The auto complete feature works better when you're chaining the endpoints, which is also the recommended way. But I wanted to break it into separate files using the createfactory API according to the docs. But the createfactory API is not smart enough to infer the types.
Steven-sensei
Steven-sensei•2mo ago
I splited my routes by creating router like you would do in express and not use factory
codeauthor
codeauthorOP•2mo ago
Wow, that's incredible! How did you pull that off? I'd love to learn more about your process.
Steven-sensei
Steven-sensei•2mo ago
GitHub
GitHub - StevenSermeus/hono-next-rpc-openapi
Contribute to StevenSermeus/hono-next-rpc-openapi development by creating an account on GitHub.
Steven-sensei
Steven-sensei•2mo ago
You can have a look there that’s my repo template
codeauthor
codeauthorOP•2mo ago
Okay. Thank you This explains it. I guess I have to swap to zod openapi. Thank you
Steven-sensei
Steven-sensei•2mo ago
No you don’t it’s juste that i needed thé open api
codeauthor
codeauthorOP•2mo ago
Oh... Sadly Hono doesn't have a built in createRoute API.
Steven-sensei
Steven-sensei•2mo ago
GitHub
template-hono-next-rpc/packages/api/src/routes at main · StevenSerm...
Repo template for a project with a Monorepo using bun with Hono, Next.Js and hono client + react-query - StevenSermeus/template-hono-next-rpc
Steven-sensei
Steven-sensei•2mo ago
It's another template for mono repo The only thing you miss in autocomplete is status from the middleware
codeauthor
codeauthorOP•2mo ago
This is great.... This is the endpoints chaining I was talking about. I wanted something more like node and Express.
Steven-sensei
Steven-sensei•2mo ago
It's how you do in node and express with you express router dk what you mean
codeauthor
codeauthorOP•2mo ago
I wanted to group related endpoints. And have a separate file for route handling
Want results from more Discord servers?
Add your server