From 017bfef8ba0f3db61335cb81fdda14360f2e1af3 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Fri, 6 Dec 2013 14:19:03 -0800 Subject: [PATCH] remove the compose and cookies examples moved to koajs/examples with tests --- examples/compose.js | 50 --------------------------------------------- examples/cookies.js | 13 ------------ 2 files changed, 63 deletions(-) delete mode 100644 examples/compose.js delete mode 100644 examples/cookies.js 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