by quarterto · 12y ago · 0 comments
5s: "designed by the team behind Express" (wait what?)
6s: "Through leveraging generators Koa allows you to ditch callbacks" (wow, ok. oh hey, that makes "next generation" not just marketing fluff)
18s:
app.use(function *(next){
var start = new Date;
yield next;
var ms = new Date - start;
this.set('X-Response-Time', ms + 'ms');
});
(oh sweeet)But this is something new that looks like it can be good. I've been wondering when it would be announced, as TJ has been working on it for a while: https://github.com/visionmedia?tab=activity
> next generation web framework for node.js
I don't think they need that, just list the stand-out features first. And yes, referring to past accomplishments does give it more credibility.
This might be one of the very few instances that "next generation" is a valid statement.
https://github.com/codegangsta/martini#next
// log before and after a request
m.Use(func(c martini.Context, log *log.Logger){
log.Println("before a request")
c.Next()
log.Println("after a request")
}) function(req, res, next) {
console.log('before');
next(); // go to the next middleware handler
console.log('after the middleware stack has been traversed');
}Or for any Scheme for the last 30 years, but don't let that change your views on how "modern" you language is :)
I can't wait to drop this in to one of my projects!