toy-koa-router

1.0.3 • Public • Published

toy koa router

npm

Installation

$ npm install toy-koa-router

Example

const Koa = require('koa');
const KoaRouter = require('toy-koa-router');

const app = new Koa();
const router = new KoaRouter();

router.get('/abc/:id',
    async (ctx, next) => {
        console.log(1);
        await next();
        console.log(3);
    },
    async (ctx, next) => {
        console.log(2);
        await next();
        console.log(4);
    }
);

app.use(router.routes());

app.use((ctx, next) => {
    console.log(5);
    ctx.body = 'nice';
});

app.listen(3000);

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i toy-koa-router

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

4.65 kB

Total Files

5

Last publish

Collaborators

  • umaruchan