How to use the koa-router.middleware function in koa-router

To help you get started, we’ve selected a few koa-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iCode-labs / Node_blog_V2 / server / router.js View on Github external
////配置监听函数
    router.get('/', blog.getnews);
    router.get('/blog/:id', blog.getblog);
    router.get('/category/:category', blog.getblogbycategory);
    router.get('/tag/:tag', blog.getblogbytag);
    //admin
    router.get('/admin', admin.index);
    router.post('/api/authenticate', admin.auth);
    ////rest api
    router.get('/api/blogs', api.list);
    router.get('/api/blogs/:blogId', api.getBlog);
    router.post('/api/blogs', api.createBlog);
    router.put('/api/blogs', api.updateBlog);
    router.delete('/api/blogs/:blogId', api.deleteBlog);
    //load router
    app.use(router.middleware());
    return app;
}

koa-router

Router middleware for koa. Maintained by Forward Email and Lad.

MIT
Latest version published 2 months ago

Package Health Score

87 / 100
Full package analysis