Short answer :
You can use sync function as well, it will work perfectly.
Long answer :
Promise vs async
Async function can be replaced by synchronous functions returning Promise into a sync function (see http://2ality.com/2016/10/async-function-tips.html for more info)
Koa compose
Koa is using koa-compose to handle middlewares.
If you check compose function in
https://github.com/koajs/compose/blob/master/index.js
Code is
return Promise.resolve(fn(context, function next () {
return dispatch(i + 1);
}))
Your middleware function fn
is then bound into Promise.resolve
which means that the output will be considered as a Promise even if you return non-Promise.
Sync Promise
It's not documented anywhere and would suggest you to avoid using undocumented patterns and I would do :
app.use(function(context){
// ...
return Promise.resolve();
})
As a sync design compatible with async.