curveball / core

The Curveball framework is a TypeScript framework for node.js with support for modern HTTP features.
https://curveballjs.org/
MIT License
526 stars 7 forks source link

Static middleware missing? #170

Closed spidgorny closed 3 years ago

spidgorny commented 3 years ago

I could not find any static middleware (serving static files from a folder). I've made my own, will gladly share with everybody. What's the best way? Copy/paste here in the issue for the maintainer to have a look?

evert commented 3 years ago

Hi @spidgorny ,

There is an official one since about 2 months, here: https://github.com/curveball/static

I hope it does what you need. If not, contributions are welcome!

spidgorny commented 3 years ago

Thank you. My version is less organized, but supports brotli compression. https://gist.github.com/spidgorny/0ee06844e17267a1c001e10e1bd307ac

evert commented 3 years ago

@spidgorny i wonder, is brolti compression really something you'd wanna do on the fly for each request? My understanding is that it's really hard on CPU.

I think an official version of brotli compression would ideally be part of a caching middleware that not only compresses, but also stores the compressed objects for re-use as long as the cache is remains valid.

spidgorny commented 3 years ago

You are right. This is probably an overkill for a general purpose library. In my case though (high CPU, low bandwidth) this was exactly what I was looking for. I'd use your suggestion next time. This issue can be closed.