Hono

H

Hono

This is the official Hono discord server for the community

Join

How to use Validator ? Context is not finalized

As soon as I try to use validator, Hono complains. api-hono:dev: error: Context is not finalized. Did you forget to return a Response object or await next()? ...

zod-openapi infering route handler type from route handler

I've been trying for two hours to create a type helper for the route handler so I can extract it to its own file, but I can't figure out why the valid property is not working. I saw cj using it in his syntax hono introduction https://youtu.be/sYZW8TK2IV4?si=iCCHBmv7vA88Phya...
No description

Multiple platforms, same project

Hi! I was wondering if I could have, for the same monorepo, a hono instance to deploy with NodeJS to a traditional long-running server, and also have another instance to be able to deploy to vercel or aws lambda for stuff like cronjobs.

basicAuth context?

Just tried out hono and wanted to add basic auth and wanted to pull data from the Env but the context is any instead of what's set on the Bindings. what am i doing wrong here? ```ts import { Hono } from 'hono' import { basicAuth } from 'hono/basic-auth'...

Looking for demo repo on how to implement tests

Hey there, Is there a demo repository out there that contain tests ? I'm looking for which command to put in my package.json, and some basic exemples on how to test routes, etc. Thanks!...

Weird bug: JSON data not making it to server: RPC

Hi all, I am sending some data to my Hono server like so: ``` const places = await api.map.getPlaces.$post({...
No description

event.pathParameters not populated on AWS Lambda event object

I have an existing AWS Lambda + API Gateway application that I am moving onto Hono. Here is my basic code: ``` type Bindings = {...

Trace when body is consumed

I have a middleware that's basically ```js if (cache.has(key)) { return cache.get(key).clone() }...

Creating custom webhooks

Hello, I'm trying to figure out how to create custom webhooks in Hono. I couldn't find any documentation on this topic. Does anyone have any direction? I have a long running function at one of my endpoints and want to allow users to subscribe to this endpoint and be told when it's done. This is achievable in Hono, right?

How to keep SSE alive with PSQL?

I have a PSQL client and I wish to send the logs via SSE. I am using the LISTEN/NOTIFY syntax where I can attach handlers to the client.on('notification'). As I understand it from the docs, I need to have a while loop to keep the connection alive, but at the same time, this code causes infinite listeners on postgres (which errors). How can I do this?...
No description

Recommendation on libraries for relatively small project

I am new to Hono and CFW. I want to use Cloudflare workers with Hono to convert an old website I wrote many years ago in Classic ASP to a modern framework as a learning exercise. After that, I have some other .NET apps I want to convert. But, I'm stuck on some basics. Using ChatGPT I got a basic API working with Hono and Workers. But to my surprise, serving static content is not straight forward. I want to keep my project as simple as possible, but it seems i need to setup Cloudflare pages as well. I want to be able manage the static content and Worker code in the same project. I also want to use templates for the HTML content. I'm familiar with Handlebars but I'm not sure that's ideal here. I want to use whatever is best and lightweight/fastest for my project....

server static file + caching

Hey guys, I am serving a static folder called public and it's all working well, I can access my files, eg styles.css. Here is the code for it: ```ts...

doc endpoint returns 500 with no errors in logs

I am running on Lambda. I have used ts-to-zod to convert some of my types to zod definitions. I have the following code: ``` const app = new OpenAPIHono<{ Bindings: Bindings }>(); app.use("*", cors());...

Bun + Hono doesn't work for me.

Hi, folks. Wanted to try hono with bun, but wasn't successful. I tried to fix it by myself with google and chatgpt, but also wasn't succesful. May I ask you folks to help? ``` bun -v 1.1.26 ➜ bun create hono hono_test ...

How to work with node:cluster in Bun?

I tried to test hono with node:cluster module that has just been added to Bun v1.2.25 Here are my scripts: server.js ```js...

how to use with hono WorkerEntrypoint

Hi, I'm using hono and cloudflare workers. I'm using 3 workers and I'd like to communicate with a 4th one that acts as a gateway, that is, that validates the token and redirects the requests to their respective workers. According to the cloudflare workers documentation, this should be done using service binding plus RPC so that they are private, but I don't know how to adapt it to hono. according to the documentation it should be like this ```js import { WorkerEntrypoint } from "cloudflare:workers";...

Email Templates

Hello, anyone tried creating email templates in hono? I tried react-email however I had no luck as it shows a lot of errors. Anything that could help is much appreciated. Thank you!
No description

Argument type string is not assignable to parameter type keyof E["Variables"]

I'm using Hono with Webstorm and whenever I use .get() or .set() with some key of string, webstorm will always complain such type mismatch. Even the type-safe guard on docs doesn't help. The code: https://github.com/search?q=repo%3Aminhperry%2Fcf-worker-backend%20c.get(&type=code...
No description

Cloudflare KV not inserting values

Why doesn't this ADD the user to the KV namespace?. Using cloudflare pages
No description

Knex + Hono + Bun Connection Errors

I was using knex on bun+hono and was attempting to make a connection via the following syntax ``` import { Knex, knex } from 'knex'; import pg from 'pg';...