Hono

H

Hono

This is the official Hono discord server for the community

Join

Websockets with honox

Good day everyone, I recently created a new project to try out something with webrtc and I decided to use websockets as my signalling mechanism. I am using honox as my 'meta-framework' and would like to know how to inject the websocket 'helper' into my server (as I do not have access to the server in the project, only the app). Any and all help would be appreciated, TIA.

Scalar, hono and hono/zod-openapi

Scalar documentation was working great in my projectuntil a while ago, now I suddenly get `` { "message": "Unknown zod object type, please specify type and other OpenAPI props using ZodSchema.openapi`.", "data": {...

Vitest with Hono

Has anyone been able to exand the basic app that comes with npm create hono@latest my-app -> "cloudflare workers" to work with vitest? I tried to reference the blog example that uses vitest but running into multiple issues. It would be great is the template came with vitest to work with hono/workers as I asuume this would be the default choice for antone starting anew project on hono. Here is my repo with this attempt: https://github.com/lane711/sonicjs/tree/feature/rebuild-vite

throw new ERR_MODULE_NOT_FOUND [Nodejs Template]

Following this guide https://hono.dev/docs/getting-started/nodejs#dockerfile i'm trying to create two scripts: one for build ("tsc") and anthoer for start the build ("node dist/index.js) buit i got this error ```2024-08-19 11:47:09 node:internal/modules/esm/resolve:265...

How to separate code into files for each handler without loosing the hono RPC typesafety?

I have an auth route , which i separated into its own file. But each route with method and handler are chained in one file and it already has 400+ lines of code. When trying to separate it into files and chain them all in index.ts with route(), RPC start to loose typesafety. Can someone share some patterns on how to do something like this ?

Hono RPC + Clerk Middleware in Next.js Server Actions/Components

I am using the clerkMiddleware in Hono and was wondering if this is the correct way to make authenticated requests with serverComponents and server Actions by simply forwarding the cookie value from the next/headers. Should there any other headers be forwarded? Here are the steps: 1) Add Hono Middleware...

RPC Type confusion

The RPC package has some unexpected behaviours and I'm hoping someone can give me some insight. This is the return value of the API route (pic 1) and what it's shown as on the other end of RPC (pic 2)...
No description

How to add custom message to error Bearer Auth

``` export const auth = bearerAuth({ verifyToken: async (accessToken: string, c: AppContext) => { try { const jwtPayload: JWTPayload = await verifyAccessToken(accessToken);...

Live Reload With Deno

I am using the Deno runtime with Hono and I was looking for a way to add live reload. I have searched for module but with little success. Can anyone point me in the direction of a resource so I can get the browser to refresh on save? Cheers Jim...

Return early from middleware

Hello, I want to return a 200 response from a middleware if certain conditions are not met, else run await and cleanup after the await. How can I return early from the middleare function?

Websockets connected clients count

Hi, I'd like to know how to get the amount of connected clients. ```ts import { Hono } from 'hono' import { upgradeWebSocket } from 'hono/cloudflare-workers'...

Hosting Hono Bun on GCP Cloud Run

Has anyone managed to get an instance running with Hono Bun running on Cloud Run and is willing to share their Dockerfile and package.json for it?

Type safety for middleware that sets context variables

I have an authentication middleware which ensures the user is logged in and adds the user to the context if they are. My middleware adds the type of this context variable per the docs: ```typescript declare module "hono" { interface ContextVariableMap {...

Error per route

Hello everyone, this is a very basic question but I couldn't find any help online. I was just wondering if it was possible to have any error handling callback per route. For example with this code, how would you handle this error only for this route ? I know I can use .onError but that would be global right ? ...

Use OpenAPI operationId inside Middleware

It's possible to use the Zod OpenAPI operationId route value inside a middleware?

FormData with images and string

I'm getting 4 images from with username, email and password from frontend. I want to process and save all the files in my local directory and path in database with username, email and password. I'm not able to find any solution on internet. Can I do this without multer or busboy? If someone done this or have an idea please share...

Hono client issues with newrelic?

Guys, I almost gave up.. I cant solve the issue: - I added newrelic for monitoring - All my endpoints goes to 401 Unauthorized ...

Match both `/` and `/:id` routes the the same router

Hello, is there any way to handle 2 routes in the same router? We want to handle requests coming to both / and /:id to handle when id is undefined or has a value.

Server Sent Events

Hello guys! Sorry if this was asked before. I'm trying to implement an event emitter with SSE like this: ```ts const emitter = new EventEmitter(); app.use("/sse/*", async (c, next) => {...

Zod why error

My code: ``` app.openapi(createRoute({ method: 'get' as any,...
No description