Skip to content

Instantly share code, notes, and snippets.

@edhaase
Created August 8, 2015 23:21
Show Gist options
  • Save edhaase/91862e2e2ecc9725172f to your computer and use it in GitHub Desktop.
Save edhaase/91862e2e2ecc9725172f to your computer and use it in GitHub Desktop.
var koa = require('koa');
var app = koa();
var router = require('koa-router')();
var util = require('util');
var compress = require('koa-compress')
app
.use(compress({
threshold: 5,
flush: require('zlib').Z_SYNC_FLUSH
}))
.use(router.routes())
.use(router.allowedMethods());
router['get']('/', function *(next) {
this.body = 'Hello World';
});
router['put']('/', function *(next) {
this.body = 'Hello World';
});
// Clearing the router works the same.
// router.stack = [];
console.log(util.inspect(router, {depth: null, color: true}));
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment