Git Product home page Git Product logo

cottage's Introduction

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
[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

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

License: MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.