diff --git a/examples/compose.js b/examples/compose.js deleted file mode 100644 index d5c047a..0000000 --- a/examples/compose.js +++ /dev/null @@ -1,50 +0,0 @@ - -var compose = require('koa-compose'); -var koa = require('..'); -var app = koa(); - -// x-response-time - -function responseTime(){ - return function *responseTime(next){ - var start = new Date; - yield next; - var ms = new Date - start; - this.set('X-Response-Time', ms + 'ms'); - } -} - -// logger - -function logger(){ - return function* logger(next){ - var start = new Date; - yield next; - var ms = new Date - start; - console.log('%s %s - %s', this.method, this.url, ms); - } -} - -// response - -function respond() { - return function* respond(next){ - yield next; - if ('/' != this.url) return; - this.body = 'Hello World'; - } -} - -// composed middleware - -function all() { - return compose([ - responseTime(), - logger(), - respond() - ]); -} - -app.use(all()); - -app.listen(3000); diff --git a/examples/cookies.js b/examples/cookies.js deleted file mode 100644 index 3a4c316..0000000 --- a/examples/cookies.js +++ /dev/null @@ -1,13 +0,0 @@ - -var koa = require('..'); -var app = koa(); - -app.use(function *(){ - if ('/favicon.ico' == this.path) return; - var n = ~~this.cookies.get('view') || 1; - this.cookies.set('view', n + 1); - this.body = n + ' views'; -}); - -app.listen(3000); -console.log('listening on port 3000'); \ No newline at end of file