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:
TJ Holowaychuk 2015-10-24 17:49:32 -07:00
commit 0cbe1cab6f

View file

@ -7,7 +7,7 @@
const isGeneratorFunction = require('is-generator-function');
const debug = require('debug')('koa:application');
const Emitter = require('events').EventEmitter;
const Emitter = require('events');
const onFinished = require('on-finished');
const response = require('./response');
const compose = require('koa-compose');
@ -115,9 +115,7 @@ module.exports = class Application extends Emitter {
res.statusCode = 404;
const ctx = this.createContext(req, res);
onFinished(res, ctx.onerror);
fn(ctx).then(function() {
respond(ctx);
}).catch(ctx.onerror);
fn(ctx).then(() => respond(ctx)).catch(ctx.onerror);
};
}