question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New middleware structures, and how we manage

See original GitHub issue

I 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:

  1. Remove graphqh-server middleware from honojs/hono repository. And move it to honojs/graphql-server.
  2. Publish as @honojs/graphql-server on the npm repository.
  3. Make honojs/firebase-auth repository.
  4. Add @Code-Hex to GitHub honojs org and add privileges to manage honojs/firebase-auth repository.
  5. Make @honojs/firebase-auth
  6. 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:closed
  • Created a year ago
  • Reactions:3
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
yusukebecommented, Jul 11, 2022

@Code-Hex Thank you!

What do you think about the release flow for npm?

I was just thinking about it!

I think we should support deployment via GitHub Actions.

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

1reaction
metruecommented, Jul 14, 2022

I think it’s great to manage the third-party middleware in individual repo, which benefits,

  • development it’s flexible to try new techs.
  • maintenance easer code review and simple CI/CD pipeline.
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Middleware? (And How Does it Work?) | Talend
Middleware is software that bridges gaps between other applications, tools, and databases in order to provide unified services to users.
Read more >
What Is Middleware? Definition, Architecture, and Best Practices
Middleware is a layer of software that enables interaction and transmission of information between assorted applications and services that ...
Read more >
Middleware - Laravel - The PHP Framework For Web Artisans
To create a new middleware, use the make:middleware Artisan command: php artisan make:middleware EnsureTokenIsValid. This command will place a new ...
Read more >
What is Middleware and How Does it Work? - Cleverism
Middleware includes software like content management systems, application servers, web servers, and other similar tools that support the ...
Read more >
What is middleware? - Red Hat
Middleware can include application runtimes, enterprise application integration and various kinds of cloud services. Data management ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found