在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:therne/cottage开源软件地址:https://github.com/therne/cottage开源编程语言:JavaScript 100.0%开源软件介绍:Cottage is the fastest, simple, and intuitive HTTP router framework for Koa.js.
InstallationCottage requires Node v8.0.0 or higher.
Exampleimport { 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!')); PerformanceBenchmark 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
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. DocumentationsLicense: MIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论