8000 GitHub - edoko/cottage: Simple, fast HTTP router on koa.js.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

edoko/cottage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cottage

Join Gitter chat Show build status Coverage report npm Version

Cottage is the fastest, simple, and intuitive server framework built on Koa.js.

  • Fastest Framework on Node - See performance
  • 100% Koa.js compatible - You can use all plugins and modules of Koa v2.
  • Simple code - Aren't you tired using res.send or ctx.body? Why can't we just return the response?
  • Additional Sugar Features

Installation

$ npm install --save cottage

Cottage requires Node v7.6.0 or higher. To use it with older versions, you must use Babel's require hook to transpile code.

Example

const Cottage = require('cottage');
const app = new Cottage();

app.post('/', async () => 'Hello world!');

app.get('/hello', async ctx => {
    const hello = await asyncHello();
    return hello; // just return data
});

// 100% fully compatible with koa
app.use(koaMiddleware());

// because cottage is built on the top of Koa.
(new Koa).use(app.callback()).listen(8080);

// simple shorthand without importing Koa.
app.listen(8080);

Performance

Benchmark have been ran on Intel Xeon E3-1250v3 @ 3.50ghz with Node.js 6.1.0 single instance. Tested from Github API sample using wrk

Framework Mean Throughput (req/sec) Stddev
cottage@2.1.0 15130.12 142.45
express@4.13.4 11455.67 201.95
koa-router@5.4.0 12279.01 157.33
hapi@13.4.1 2402.31 53.14

As the benchmark result shows, cottage is the fastest framework in Node.js.

Why?

Cottage uses Radix Tree for URL routing, which is faster than any other data structures. Also, cottage uses technique called "middleware precomposition", which precomposes middleware only at first time, not the every runtime.

Documentations

  • API Documentation (Currently Working)
  • Samples (Currently Working)

License: MIT

About

Simple, fast HTTP router on koa.js.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%
0