Skip to content
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

feat: middleware for compatibility with express/connect for Hono #928

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

EdamAme-x
Copy link
Contributor

@EdamAme-x EdamAme-x commented Jan 9, 2025

resolve: honojs/hono#3293

Still some concerns and bugs.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • yarn changeset at the top of this repo and push the changeset
  • Follow the contribution guide

Copy link

changeset-bot bot commented Jan 9, 2025

🦋 Changeset detected

Latest commit: b393f28

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/connect Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@EdamAme-x EdamAme-x marked this pull request as draft January 9, 2025 02:11
@EdamAme-x
Copy link
Contributor Author

hi @yusukebe

There are two problems with this implementation.

The first is regarding the header update process.

This test fails.
https://github.com/honojs/middleware/pull/928/files#diff-05c9dabcbf8c76abe4ba387843468024649359e039e0f521ed755f44de39ca44R38-R43

Here is the cause.
https://github.com/honojs/middleware/pull/928/files#diff-e82bf8d64b2d70f2d39b9aa64ada59b6d93549da4aa4f72f7c9f15e3d7426fb0R43

The header is not removed successfully.

@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Jan 9, 2025

Second, even using “next” internally does not count as Hono's overall middleware.
It is instantiated once internally and the request is passed on.

However, this problem can be sufficiently avoided by being careful about the order of execution.

(It is obvious that the performance is quite bad)

@EdamAme-x EdamAme-x changed the title feat: an middleware for compatibility with express/connect for Hono feat: middleware for compatibility with express/connect for Hono Jan 15, 2025
@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Jan 15, 2025

ToDo: mark as dev deps
"helmet": "^8.0.0",

Co-Authored-By: sor4chi ([email protected])
@EdamAme-x EdamAme-x marked this pull request as ready for review January 15, 2025 03:45
@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Jan 15, 2025

hi @yusukebe @sor4chi
Do you know any reason why the header cannot be removed successfully here?

https://github.com/honojs/middleware/pull/928/files#diff-e82bf8d64b2d70f2d39b9aa64ada59b6d93549da4aa4f72f7c9f15e3d7426fb0R43

@yusukebe
Copy link
Member

Hi @EdamAme-x

I think this approach is okay (actually, there is only this way), though the overheads are heavy as you said. I'll check the problems.

@EdamAme-x EdamAme-x marked this pull request as draft January 15, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Express.js Compatible Middleware
2 participants