New middleware structures, and how we manage
See original GitHub issueI want to renew middleware structures for v2.0.0. I’ll tell you my plan roughly.
There are two types of middleware:
1. Built-in middleware
Basic. It does not depend on other libraries. Such as basic-auth
, cors
, etag
, jsx
, and so on. Included in hono
packages. So, we can use hono/{name}
syntax like this:
const { cors } from 'hono/cors'
2. Third-party middleware
Extended. It depends on other libraries. Such as graphql-server
, mustache
, or firebase-auth
. These are not included in hono
package but distributed by @honojs/{name}
package. like this:
// Install
npm i graphql
npm i @honojs/graphql-server
// Code
const { graphqlServer } from '@honojs/graphql-server'
And, these middleware are managed in under honojs
org on GitHub. Each middleware has its own repository. Such
https://github.com/honojs/graphql-server
honojs
org in npm
Already, I’ve got honojs
org in the npm repository.
https://www.npmjs.com/org/honojs
We can use @honojs/{name}
namespace.
Privileges
We have to think about the privileges of managing third-party middleware.
Basically, I keep managing github.com/honojs/hono
for hono
package including built-in middleware.
And, the GitHub repository and npm package of third-party middleware is managed by the author of it. To do it I’ll give privileges to access GitHub and npm repo to the author of the middleware.
For example. If @Code-Hex wants to make firebase-auth
middleware, I will give the privileges to manage GitHub github.com/honojs/firebase-auth
and npm @honojs/firebase-auth
. The author is free to use the repository for development and release it to npm freely.
How to
For example:
- Remove
graphqh-server
middleware fromhonojs/hono
repository. And move it tohonojs/graphql-server
. - Publish as
@honojs/graphql-server
on the npm repository. - Make
honojs/firebase-auth
repository. - Add @Code-Hex to GitHub
honojs
org and add privileges to managehonojs/firebase-auth
repository. - Make
@honojs/firebase-auth
- Add @Code-Hex to the npm repository
honojs
and add privileges to release and manage@honojs/firebase-auth
.
It’s just an idea. We have to consider it.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:9 (1 by maintainers)
Top GitHub Comments
@Code-Hex Thank you!
I was just thinking about it!
I think so, it’s a better solution. So, I’ll try to set up GitHub Actions with
middleware-template
repository later. I’ve had a quick look, and this GitHub Action looks good.https://github.com/marketplace/actions/publish-to-npm
I think it’s great to manage the third-party middleware in individual repo, which benefits,