Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Koa boilerplate code
import Router from 'koa-router';
export function moduleMiddleware(options = {}) {
const router = new Router();
router.get('/', async (ctx, next) => {
// ... do some job
});
return router;
}
import Koa from 'koa';
import config from 'config';
import {moduleMiddleware} from './middleware.js';
const app = new Koa();
app.use(moduleMiddleware());
app.listen(config.server.port, config.server.host, function () {
console.log('%s listening at port %d', config.app.name, config.server.port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment