-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Express middleware for submounting Hono app #934
Comments
@sor4chi Thanks! Related to #928 by @EdamAme-x |
Wow, we already had a proposal! |
BTW, the code that @EdamAme-x is suggesting is Express on Hono, but what I want to propose here is Hono on Express. In reality, it would be quite challenging for an organization that uses Express to suddenly replace it with Hono, so I would like to propose a bottom-up migration approach. |
I thought so too. In Hono
In Express (Connect)
|
const app = express()
app.use('/hono', hono(new Hono().get('/', (c) => c.text('Hello Hono in Express!'))))
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000')
}) It seems difficult. |
Ah, super sorry! I misunderstood. It can be enabled by using the Node Adapter: import { Hono } from 'hono'
import { getRequestListener } from '@hono/node-server'
import express from 'express'
const hono = new Hono()
hono.get('/', (c) => c.text('Hello from Hono!'))
const app = express()
app.use('/hono', getRequestListener(hono.fetch))
app.listen(3000) |
Yes, that's true, but when considering usage in an actual environment, I think it will be necessary to pass things like loggers and DB connections, which can usually be included in the context, from Express to Hono. |
Which middleware is the feature for?
@hono/express
What is the feature you are proposing?
As I presented at Hono Conf 2024, if we can mount Hono as a sub-application of Express, it would enable a gradual migration from Express to Hono, which could increase the motivation to use Hono.
As a precedent, there is a framework with a similar motivation called @fastify/express.
I already have a POC implementation in hand, but I wanted to raise an issue for discussion. How do you think?
The text was updated successfully, but these errors were encountered: