2013-09-03 02:28:54 +00:00
|
|
|
|
|
|
|
var koa = require('..');
|
|
|
|
var fs = require('co-fs');
|
|
|
|
var app = koa();
|
|
|
|
|
|
|
|
// read docs/*.md in parallel
|
|
|
|
// and return a joined response
|
|
|
|
|
|
|
|
app.use(function(){
|
|
|
|
return function *(){
|
|
|
|
var paths = yield fs.readdir('docs');
|
|
|
|
|
|
|
|
var files = yield paths.map(function(path){
|
|
|
|
return fs.readFile('docs/' + path, 'utf8');
|
|
|
|
});
|
|
|
|
|
|
|
|
this.type = 'markdown';
|
2013-09-03 02:31:11 +00:00
|
|
|
this.body = files.join('');
|
2013-09-03 02:28:54 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(3000);
|