Update docs - add template strings and arrow functions where applicable
This commit is contained in:
parent
95a5bcd3e0
commit
863fce310b
2 changed files with 5 additions and 7 deletions
|
@ -64,7 +64,7 @@ app.use(function *(next){
|
||||||
const start = new Date;
|
const start = new Date;
|
||||||
yield next;
|
yield next;
|
||||||
const ms = new Date - start;
|
const ms = new Date - start;
|
||||||
this.set('X-Response-Time', ms + 'ms');
|
this.set('X-Response-Time', `${ms}ms`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// logger
|
// logger
|
||||||
|
@ -73,7 +73,7 @@ app.use(function *(next){
|
||||||
const start = new Date;
|
const start = new Date;
|
||||||
yield next;
|
yield next;
|
||||||
const ms = new Date - start;
|
const ms = new Date - start;
|
||||||
console.log('%s %s - %s', this.method, this.url, ms);
|
console.log(`${this.method} ${this.url} - ${ms}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// response
|
// response
|
||||||
|
|
|
@ -17,7 +17,7 @@ function *responseTime(next) {
|
||||||
const start = new Date;
|
const start = new Date;
|
||||||
yield next;
|
yield next;
|
||||||
const ms = new Date - start;
|
const ms = new Date - start;
|
||||||
this.set('X-Response-Time', ms + 'ms');
|
this.set('X-Response-Time', `${ms}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(responseTime);
|
app.use(responseTime);
|
||||||
|
@ -30,7 +30,7 @@ app.use(function *(next){
|
||||||
const start = new Date;
|
const start = new Date;
|
||||||
yield next;
|
yield next;
|
||||||
const ms = new Date - start;
|
const ms = new Date - start;
|
||||||
this.set('X-Response-Time', ms + 'ms');
|
this.set('X-Response-Time', `${ms}ms`);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -223,9 +223,7 @@ const fs = require('co-fs');
|
||||||
app.use(function *(){
|
app.use(function *(){
|
||||||
const paths = yield fs.readdir('docs');
|
const paths = yield fs.readdir('docs');
|
||||||
|
|
||||||
const files = yield paths.map(function(path){
|
const files = yield paths.map(path => fs.readFile(`docs/${path}`, 'utf8'));
|
||||||
return fs.readFile('docs/' + path, 'utf8');
|
|
||||||
});
|
|
||||||
|
|
||||||
this.type = 'markdown';
|
this.type = 'markdown';
|
||||||
this.body = files.join('');
|
this.body = files.join('');
|
||||||
|
|
Loading…
Reference in a new issue