Member-only story
Let’s build a REST API with Koa.js and test with Jest!

Background
Up and until recently I’ve been using express for my node routes. It’s been a good run, but I’m here to tell you that Koa is superior.
From their website.
Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs. Through leveraging generators Koa allows you to ditch callbacks and greatly increase error-handling. Koa does not bundle any middleware within core, and provides an elegant suite of methods that make writing servers fast and enjoyable.
What I love about it
- The whole framework is built on async/await
- It brings practically nothing other than basic routing, so that makes it incredibly light-weight.
- It was built by the express people as a replacement.
- Simplest error Logging I’ve ever seen.
Koa vs Express
I’m not going to sit here and babble on about it, when much smarter people have talked about it, here and here.
Alternatively, if you don’t want to read this at all, and just want to see the final code, check out the repo: