반응형

Koa: A next-gen Node.js web framework

koa

 

Expressive middleware for node.js using generators

 

Expressive middleware for node.js using generators via co to make web applications and APIs more enjoyable to write. Koa's middleware flow in a stack-like manner allowing you to perform actions downstream, then filter and manipulate the response upstream. Koa's use of generators also greatly increases the readability and robustness of your application.

Only methods that are common to nearly all HTTP servers are integrated directly into Koa's small ~400 SLOC codebase. This includes things like content-negotiation, normalization of node inconsistencies, redirection, and a few others.

No middleware are bundled with koa. If you prefer to only define a single dependency for common middleware, much like Connect, you may use koa-common.

Installation

$ npm install koa

To use Koa you must be running node 0.11.9 or higher for generator support, and must run node(1) with the --harmony flag. If you don't like typing this, add an alias to your shell profile:

alias node='node --harmony'

Another option, if you would like to use koa with node 0.10.x (the current stable branch), or are tired of typing the --harmony flag, is to use gnode to spawn your node instance. However note that performance degrades quickly compared to 0.11.x.

Community

 

반응형

+ Recent posts