From 08797ccb0bec33281baef5719f93af794fc3e69d Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sat, 7 Dec 2013 15:08:02 -0800 Subject: [PATCH] remove errors, hello world, and stream examples --- examples/errors.js | 37 ------------------------------------- examples/hello-world.js | 9 --------- examples/streams.js | 13 ------------- 3 files changed, 59 deletions(-) delete mode 100644 examples/errors.js delete mode 100644 examples/hello-world.js delete mode 100644 examples/streams.js diff --git a/examples/errors.js b/examples/errors.js deleted file mode 100644 index e4f5dd1..0000000 --- a/examples/errors.js +++ /dev/null @@ -1,37 +0,0 @@ - -var koa = require('..'); -var app = koa(); - -// look ma, error propagation! - -app.use(function *(next){ - try { - yield next; - } catch (err) { - // some errors will have .status - // however this is not a guarantee - this.status = err.status || 500; - this.type = 'html'; - this.body = '

Something exploded, please contact Maru.

'; - - // since we handled this manually we'll - // want to delegate to the regular app - // level error handling as well so that - // centralized still functions correctly. - this.app.emit('error', err, this); - } -}); - -// response - -app.use(function *(){ - throw new Error('boom boom'); -}); - -// error handler - -app.on('error', function(err){ - console.log('sent error %s to the cloud', err.message); -}); - -app.listen(3000); diff --git a/examples/hello-world.js b/examples/hello-world.js deleted file mode 100644 index c6786f7..0000000 --- a/examples/hello-world.js +++ /dev/null @@ -1,9 +0,0 @@ - -var koa = require('..'); -var app = koa(); - -app.use(function *(){ - this.body = 'Hello World'; -}); - -app.listen(3000); diff --git a/examples/streams.js b/examples/streams.js deleted file mode 100644 index 4002867..0000000 --- a/examples/streams.js +++ /dev/null @@ -1,13 +0,0 @@ - -var koa = require('..'); -var fs = require('fs'); -var app = koa(); - -// try GET /streams.js - -app.use(function *(){ - var path = __dirname + this.path; - this.body = fs.createReadStream(path); -}); - -app.listen(3000);