Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Koa = require('koa')
- const Router = require('@koa/router')
- class MyRouter extends Router {
- routes() {
- console.log(this.stack)
- return super.routes()
- }
- }
- const router = new MyRouter()
- router.get('/', async (ctx, next) => {
- ctx.body = 'default middleware'
- })
- router.get('/', async (ctx, next) => {
- ctx.body = 'my middleware'
- })
- const app = new Koa()
- app.use(router.routes())
- app.listen(3000)
Advertisement
Add Comment
Please, Sign In to add comment