Skip to content

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.listen(config.server.port,, function () {
console.log('%s listening at port %d',, config.server.port);

This comment has been minimized.

Copy link

@khusamov khusamov commented Aug 28, 2018

Ошибка! На 10-й строке middleware.js должно быть return router.routes().
Ссылка на документацию

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment