spirit-js / spirit

Modern modular library for building web applications
http://spirit.function.run
ISC License
244 stars 18 forks source link

Feature Request: Support for Koa Middleware #20

Open Lichtjaeger opened 6 years ago

Lichtjaeger commented 6 years ago

Hi,

It would be very nice if there would be a middleware handler for koa like you did it with spirit-express.

hnry commented 6 years ago

Sure, is koa2 only reasonable? koa2 seems very similar in design (bidirectional, flows upstream and downstream just like spirit).

Any particular koa2 middleware you were looking at? Or can you name some popular must-have ones? This is just so I can use them to test against. For example for express compatibility there were some popular middlewares that did some hacky stuff to work and I had to account for it.

Lichtjaeger commented 6 years ago

Yes, we should focus on koa2. I came up with it because of this article. The first implementation of the Aurelia server-side rendering middleware will be for koa2. I also failed to make oidc-provider work with spirit-express. It is itself a koa2 middleware/server with express compatibility. I would assume that it works better as a koa middleware.

I originally started with express and do working with domain sessions. So I am dependent on the express-session middleware (or full compatible alternatives). Therefore I don't have much experience with koa2 and its middleware.

But the ability to use and mix the best of the express and koa2 worlds would be a big plus for spirit.

PS: The middleware I usually use in my express apps are serve-favicon, helmet, cors, multer, and compression.