• Stars
    star
    101
  • Rank 336,424 (Top 7 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, fast HTTP router on koa.js.

Cottage

Join Gitter chat Show build status Coverage report npm Version

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.send or ctx.body? Why can't we just return the 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

More Repositories

1

dmn-tensorflow

Dynamic Memory Networks (https://arxiv.org/abs/1603.01417) in Tensorflow
Python
240
star
2

compact-bilinear-pooling-tf

Compact Bilinear Pooling (https://arxiv.org/abs/1511.06062) for TensorFlow
C++
47
star
3

instauuid

Instagram-Style Compact UUID generator library for Node.js
JavaScript
43
star
4

tender

Serverless for Web3, which is Immutable and Verifiableβœ…
TypeScript
23
star
5

errorist

Utilities for coping with errors and panics like a boss in Go
Go
19
star
6

hype

Production-Ready Indexer Framework for Terra
TypeScript
18
star
7

stringenum

A go tool to auto-generate methods for enum types based on string.
Go
13
star
8

tschema

Simple and fastest static type checker for Node.js.
JavaScript
10
star
9

connect6-python

Connect6 (Korean: 윑λͺ©) for Python.
Python
10
star
10

pine-log

Simple yet powerful logger for Node.JS with contextual logging
TypeScript
10
star
11

lrmr

Less-Resilient MapReduce for Go
Go
10
star
12

relation-networks-tensorflow

WIP) A TensorFlow implementation of DeepMind's Relation Networks (https://arxiv.org/abs/1706.01427)
Python
8
star
13

vscode-theme-atom

Visual Studio Code theme for Atom Editor
CSS
7
star
14

cosmwasm-rbac

Access Control Utilities for CosmWasm smart contracts
Rust
5
star
15

til

Today I Learned
4
star
16

shape

Shape is Android UI Markup Language.
Java
2
star
17

my-env

My shell environment. Used for setting up new computers.
Vim Script
2
star
18

mansion

A full-sized, convinient framework built on cottage.
JavaScript
2
star
19

thebot

Thebot is simple, intuitive, extensible chatbot framework for Node.
JavaScript
1
star
20

droidium

Droidium is an Android manipulation & automation framework for Node.js.
JavaScript
1
star
21

tender-isolate

Isolation Runtime Server for Tender
TypeScript
1
star
22

importer

A node.js module that helps you to import (require) all sources in a directory.
JavaScript
1
star