preface

What? This is a source code interpretation of the article? That must be boring! Don’t look at.

I’ve broken down the core implementation of Koa into 7 sections, which take you step by step into the inner world of Koa. It’s not too dry to chew on

I have not used Koa, will not understand?

Each core implementation I have done practice and demo~, very easy to understand ~

What is the Koa

Koa is a new Web framework, built by the same people behind Express, that aims to be a smaller, more expressive, and more robust cornerstone of web application and API development. By making use of async functions, Koa helps you discard callback functions and greatly enhances error handling. Koa does not bundle any middleware, but rather provides an elegant way to help you write server-side applications quickly and happily.

Of Koa

The Koa source code is very lean, with only four files

  • Application.js (KOA entry, KOA middleware management, request processing, this article focuses on.)

  • Context.js (koA context object, which proxies some methods and properties of request and Response objects)

  • Request.js (koA request object, which is rewrapped based on the node HTTP module request information, and defines some properties and methods, referencing a graph, you can clearly see what the request does)

  • Response.js (KOA response object, secondary encapsulation based on the node HTTP module response information, and define some properties and methods, reference a graph, you can clearly see what response does)

Meet koa

1. Koa EventEmitter

2. Http module of Koa

3. Koa Use method

4. Koa onion model

5. Koa Context object

6. Koa source code intensive reading I

7. Koa source code intensive reading ii