Hono

H

Hono

This is the official Hono discord server for the community

Join

All GET/POST api calls returns Internal server error 500

I'm using Hono for my app https://platform.procureezy.com/workflows but it keeps returning this error for all my API calls : GET https://platform.procureezy.com/api/workflows 500 (Internal Server Error)
[[...route]] ```app.onError((err, c) => { if (err instanceof HTTPException) {...

TypeError: Response constructor: Invalid response status code 204

Hi, I seem to be getting the following error on the latest version of Hono when using any 2XX status from 204 and above. It is ocurring when I set the context status using c.status(2XX) before I return a JSON response.

@hono/zod-openapi: How to write OpenAPI doc for middleware responses?

I have an auth middleware which will check if the api token is provided in the request header, so it will respond with 401 or pass. How to make sure every protected route will be applied with the 401 response? ```typescript app.openapi(...

Experimenting with custom NextJS Server

Hey guys, I'm running into an issue where nextjs is not hydrating properly and hono is giving an error: unhandledRejection: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client Here's the code: ```ts...

How to set up and use a structured error format?

Hi; I am not strong in API design, and had a question about structuring error formats. I wish to create error formats, that are extensions of the Error instance, let's all it MY_API_ERROR_INSTANCE...

Ensuring Type Safety and Handling Optional JWT Fields in Hono Middleware

Assume I have a middleware created with createMiddleware, which extracts JWT from a cookie and decodes it. After this simple logic, the payload 100% exists. As I've understood from the docs, to pass it further to a handler, I need to use .set('name', value). To add type-safety, I've read that Variables are made for that. First Question: Where do I need to pass these variables? In the root Hono instance of my project? ...

get with params not working

Can someone help me. i have simple code: import { Hono } from "hono"; ...

Can someone explain why types aren't inferred

If I use this code then the types arent inferred whereas with the code in the second image I can
No description

hono logger with log levels

Is there anyway we can use hono logging Middleware the way we use pino js e.g.?

Serialization of Date?

Is there any suggested guidance on how to handle js/json serialization? I ran into an issue using the hono client where the types break due to a Date being typed as a string after being returned from a hono route I see there are no data transformers provided by hono, so wondering what suggestions there are. https://discord.com/channels/1011308539819597844/1248521918554963979...

unit tests with vitest, drizzle and d1

I am having problems running my hono API tests. vites.config.ts ```ts import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config' import path from 'path';...

websocket issue

```ts import { Hono } from 'hono'; import { createBunWebSocket } from 'hono/bun'; import type { WSContext, WSEvents, WSMessageReceive } from "hono/ws";...
No description

Using Hono through Bun inside a Node/Pnpm Monorepo

Hello, I would like to use Hono inside our Turborepo project, but actually we are using pnpm since many said that using bun are not stable enough. It's possible to use and deploy Hono on Bun under that context? I want to avoid the hono/node-server because it has some issues, and the ideal scenario would be able to deploy through Docker this hono instance (using turborepo prune feature)....

c.json() does not enforce OpenAPI return type

Hello there! I'm playing around Hono and RPC, and it works great, but for some reason the return type of the handler function is not enforced by the OpenAPI spec that is provided to it. I have searched on github issues and in here, but did not find anyone with the same problem. It might just be that it's not possible at the moment to do this automatically, but rather I have to type the c.json<ReturnType, 200>() myself ...

Type inference breaks after upgrading hono

(Example image at the end of post) The following code relies on type inference to work. When upgrading from Hono version 4.2.2 to 4.4.3 on both the frontend and backend, the following code broke. 1. I do an rpc fetch like this: ...
No description

ctx.req: readable stream

noticed there's documentation for sending a steam, but having difficulty reading one from the Context

Module not found: Can't resolve 'path' with Hono Drizzle

The Error
./node_modules/dotenv/lib/main.js:2:1
Module not found: Can't resolve 'path'
./node_modules/dotenv/lib/main.js:2:1
Module not found: Can't resolve 'path'
...

unable to retrieve cookie value

```ts // index.ts import { Hono } from 'hono'; import { getCookie, setCookie} from 'hono/cookie'; import CryptoJS from 'crypto-js';...

Posting files in multipart/form-data gives empty string

Hey everyone. I've run into a problem where when I try to upload a file to my hono application as multipart/form-data all I get back is an empty string. In my form I am sending a key of name expected to be a string and image expected to be a file....
No description

[zod, bun]#openapi async/await doesn't work

This ossue was previously on https://discord.com/channels/1011308539819597844/1012485912409690122/1242558525012709539, but I was advised to open it here. here is a noob question. Im quite new to TS, bun and Hono with Zod. I cant make sense of why TS is screaming at me in the first line with async ```ts apps.openapi(routeGetApp, async (c) => {...