Skip to content
forked from koajs/koa

Expressive middleware for node.js using generators

License

Notifications You must be signed in to change notification settings

bluepeople1/koa

 
 

Repository files navigation

koa middleware framework for nodejs

gitter NPM version build status Test coverage

Expressive HTTP middleware for node.js to make web applications and APIs more enjoyable to write. Koa's middleware stack flows 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 ~550 SLOC codebase. This includes things like content negotiation, normalization of node inconsistencies, redirection, and a few others.

Koa is not bundled with any middleware.

Installation

$ npm install koa

Koa requires node v4.0.0 or higher for (partial) ES2015 support.

Community

Getting started

  • Kick-Off-Koa - An intro to koa via a set of self-guided workshops.
  • Workshop - A workshop to learn the basics of koa, Express' spiritual successor.
  • Introduction Screencast - An introduction to installing and getting started with Koa

Example

const Koa = require('koa');
const app = new Koa();

// logger

app.use(function *(next){
  const start = new Date;
  yield next;
  const ms = new Date - start;
  console.log(`${this.method} ${this.url} - ${ms}`);
});

// response

app.use(function *(){
  this.body = 'Hello World';
});

app.listen(3000);

Running tests

$ make test

Authors

See AUTHORS.

License

MIT

About

Expressive middleware for node.js using generators

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.1%
  • Other 0.9%