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
orctx.body
? Why can't we justreturn
the response? - Additional Sugar Features
$ 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.
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);
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.
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.
- API Documentation (Currently Working)
- Samples (Currently Working)