refactor into multiple files
add a koa middlware