Ported from #5:
Add a middleware package that attaches helpers directly to the `res` object?
This would mimic Express, potentially offering all/most of them.
This is a low(er) priority, but would definitely be helpful for those who can't live without the Express built-ins. 馃槅
Potentially required built-ins (must needed) have to be listed...?
Sorry, don't understand what you mean
IMHO a list of must needed Express built-ins need to be made. Can't implement all of them right?
And the ones that are lighter vs heavier on perf.
Would this be implemented as a middleware that would go on an use statement?
Because I kinda have something I would like to flesh out a bit more and maybe include here.
I have 85% of the response helpers done now :) right now, some of the "big" ones are their own packages (eg, send, sendfile, redirect) but the others are grouped together and available as their own exports. I think this will be a @polka/response package:
import { link, download } from '@polka/response';
polka()
.get('*', (req, res) => {
link(res, ...);
})
These imports are just like the current "send" package. They operate independently/don't need to be used inside Polka at all.
I might also be re-exporting those bigger packages (send, redirect, etc) from this package too. Not sure yet.
Finally, and probably more importantly, there's a @polka/compat package that will auto-attach all response helpers so that you have a near-identical Express setup.
import compat from `@polka/compat`;
polka()
.use(compat)
.get((req, res) => {
res.set('X-Foo', 'custom header');
res.status(200).json({ foo: 123 });
})
I haven't released his components yet in a @next tag yet simply because I'm not exactly sure how to subdivide all these behaviors in the sane way. I don't want to risk renaming items, moving functions, etc until things are a little more concrete
Both @polka/response and @polka/compat sound like really good ideas.
The only thing that's holding me back from switching to polka from express for old projects.
What is the status of this, @lukeed? Really looking forward to this!
Thanks! I'm trying to carve out a chunk of time so that I can finish the entire Polka 1.0 suite in a 1-2 week push. All the big pieces are done 鈥撀爅ust need some documentation and some more tests.
As for this issue specifically, some of the smaller utilities are _not_ done but they may not be needed at all. The bigger pieces of this issue left TBD are cookies & fresh
Glad to hear it! The main helper we need is res.redirect; is that included in 1.0?
Yes :)
@talentlessguy Please do not go around advertising your framework in issues. Good practice in general.
@lukeed I'm sorry, I just thought these extensions would be useful for ppl who use polka and have to rewrite them from scratch
Most helpful comment
Thanks! I'm trying to carve out a chunk of time so that I can finish the entire Polka 1.0 suite in a 1-2 week push. All the big pieces are done 鈥撀爅ust need some documentation and some more tests.
As for this issue specifically, some of the smaller utilities are _not_ done but they may not be needed at all. The bigger pieces of this issue left TBD are cookies & fresh