프로젝트
GitHub에서 보기
therne/cottage
소개
Simple, fast HTTP router on koa.js.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Original
Cottage is the fastest, simple, and intuitive HTTP router framework for Koa.js.
- Fastest HTTP Router / Framework on Node - See performance
- Simple code - Aren't you tired using
res.sendorctx.body? Why can't we justreturnthe response? - Additional Sugar Features
Installation
Cottage requires Node v8.0.0 or higher.
$ npm install cottage
Example
import { Cottage, Response } from 'cottage';
const app = new Cottage();
// just simple return would be enough
app.post('/', async ctx => 'Hello world!');
app.get('/auth', async ctx => {
// needs fancy response code?
return new Response(401, { error: 'unauthorized' });
});
// cottage is built on the top of Koa.
app.use(anyKoaMiddleware());
(new Koa).use(app.callback()).listen(...);
// or a simple shorthand without importing Koa.
app.listen(8080, () => console.log('Independent!'));
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 |
|---|---|---|
| [email protected] | 15130.12 | 142.45 |
| [email protected] | 11455.67 | 201.95 |
| [email protected] | 12279.01 | 157.33 |
| [email protected] | 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
License: MIT
관련 프로젝트 살펴보기
불러오는 중…