4 ms·
Basically what I find Koa does for me: http://koajs.com http://koajs.com
by kosinus 9y ago
Basically what I find Koa does for me: http://koajs.com http://koajs.com
- vidar 9y agoI am in the Koa boat as well, does Express have anything that Koa does not? (not trying to start a framework flamewar, honestly!)
- drinchev 9y agoKoa was created by the very same person as Express itself [https://github.com/tj https://github.com/tj] TJ Holowaychuk. The initial idea is to do the next level express framework using back-then generator functions. What is missing ( for me ) is the smaller community and popularity. So it makes it tough to argue about the business impact between choosing koa over express. Honestly, being a nodeJS freelancer for the last decade there was not a single project, where koa was in use. Mostly I've seen express or sailsjs [http://sailsjs.com http://sailsjs.com] which is quite a full-blown MVC Rails style solution.
- franciscop 9y agoIMHO, and one of the reasons I decided to go with server, simplicity is a feature and the advantage of express over Koa. It is hard enough for new users to get started on Node.js, but to have to handle all of the new middleware concepts, PLUS to have to learn a lot more advanced features like generators is a no-go for my framework of choice. - server: return something to reply to the browser. Can use `async` for more advanced features. - express: reply.send() is fairly straightforward. next() for middleware is a new concept but conceptually in the right place (when you are digging a bit deeper in the middleware). - Koa: yield, function with asterisk, etc. So I think Koa is fine for devs who have been a while in JS dev, but the learning curve is too steep to get started. Same as what happens with React and the reason create-react-app has become so popular.
- kosinus 9y agoKoa has been doing async for a while. It's basically connect with promises instead of callbacks: `app.use(async (ctx, next) => { await next(); });`
- mikermcneil 9y agoAs long as you're on Node >=v7.9, you can also use `await` in Sails, Koa, or any other tool that supports promises. There's some work we had to do to make it feel nicer, and we had to update docs and stuff, but for the most part it was pretty painless-- all thanks to the JavaScript engine. And `await` is so much easier and safer than callbacks in userland code! Really excited about Node.js in 2018, now that `await` is supported in the LTS release. Callback hell is finally dead. (Diff showing a refactor of an example app from traditional callbacks to async/await: https://github.com/mikermcneil/chatkin/pull/4/files https://github.com/mikermcneil/chatkin/pull/4/files)
- nkristoffersen 9y agoI went from hapi to express simply for the plethora of middleware (specifically passport).
- HatchedLake721 9y agoReally? Hapi has its request lifecycle and built-in auth that makes auth much simpler than injecting authentication/authorization middlewares on every route.
- novaleaf 9y agoagree,also hapi has a pretty big ecosystem of middleware. a lot of it 1st party