diff --git a/lib/middleware/conditional-get.js b/lib/middleware/conditional-get.js index 7a71b49..537fe7d 100644 --- a/lib/middleware/conditional-get.js +++ b/lib/middleware/conditional-get.js @@ -14,7 +14,7 @@ module.exports = function (options) { } } - return async (next) => { + return async function (next) { yield* etag.call(this, next); if (this.request.fresh) this.response.status = 304; } diff --git a/lib/middleware/headers.js b/lib/middleware/headers.js index a0fc247..1bba6de 100644 --- a/lib/middleware/headers.js +++ b/lib/middleware/headers.js @@ -34,7 +34,7 @@ module.exports = function (app, options) { // enable by default if (nosniff != null) nosniff = true; - app.use(async (ctx, next) => { + app.use(async function (ctx, next) { ctx.response.set('X-Powered-By', 'koala, koa'); if (hsts) ctx.response.set('Strict-Transport-Security', hsts); if (nosniff) ctx.response.set('X-Content-Type-Options', 'nosniff'); diff --git a/lib/middleware/pageNotFoundHandler.js b/lib/middleware/pageNotFoundHandler.js index 02b24be..6665481 100644 --- a/lib/middleware/pageNotFoundHandler.js +++ b/lib/middleware/pageNotFoundHandler.js @@ -1,4 +1,4 @@ -module.exports = async(ctx, next) => { +module.exports = async function (ctx, next) { try { await next() const status = ctx.status || 404 @@ -12,10 +12,10 @@ module.exports = async(ctx, next) => { ctx.status = err.status || 500 if (ctx.status === 404) { //Your 404.jade - await ctx.render(`${__dirname}/404`) + await ctx.render(`${__dirname}/../templates/404`) } else { //other_error jade - await ctx.render('error', ctx) + await ctx.render(`${__dirname}/../templates/error`, ctx) } } } diff --git a/lib/middleware/trace.js b/lib/middleware/trace.js index 2380e87..e9c7f37 100644 --- a/lib/middleware/trace.js +++ b/lib/middleware/trace.js @@ -1,7 +1,7 @@ var randomBytes = require('mz/crypto').randomBytes; -module.exports = async (ctx, next) => { +module.exports = async function (ctx, next) { this.id = await randomBytes(24); var req = ctx.req; diff --git a/test/app/basic-auth.js b/test/app/basic-auth.js index aef55c6..ebbfff5 100644 --- a/test/app/basic-auth.js +++ b/test/app/basic-auth.js @@ -2,7 +2,7 @@ describe('Basic Auth', function () { it('should return the value', function (done) { var app = new Koala() - app.use(async (next) => { + app.use(async function (next) { this.body = this.request.basicAuth })