Merge pull request #547 from stojanovic/master
Refactor application.js - use arrow function in callback and remove EventEmitter from 'event' module
This commit is contained in:
commit
0cbe1cab6f
1 changed files with 2 additions and 4 deletions
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
const isGeneratorFunction = require('is-generator-function');
|
const isGeneratorFunction = require('is-generator-function');
|
||||||
const debug = require('debug')('koa:application');
|
const debug = require('debug')('koa:application');
|
||||||
const Emitter = require('events').EventEmitter;
|
const Emitter = require('events');
|
||||||
const onFinished = require('on-finished');
|
const onFinished = require('on-finished');
|
||||||
const response = require('./response');
|
const response = require('./response');
|
||||||
const compose = require('koa-compose');
|
const compose = require('koa-compose');
|
||||||
|
@ -115,9 +115,7 @@ module.exports = class Application extends Emitter {
|
||||||
res.statusCode = 404;
|
res.statusCode = 404;
|
||||||
const ctx = this.createContext(req, res);
|
const ctx = this.createContext(req, res);
|
||||||
onFinished(res, ctx.onerror);
|
onFinished(res, ctx.onerror);
|
||||||
fn(ctx).then(function() {
|
fn(ctx).then(() => respond(ctx)).catch(ctx.onerror);
|
||||||
respond(ctx);
|
|
||||||
}).catch(ctx.onerror);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue