19.0.1 • Published 4 years ago

@seregpie/koa-route v19.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

KoaRoute

A simple route middleware.

dependencies

setup

npm i @seregpie/koa-route

usage

let Koa = require('koa');
let KoaRoute = require('@seregpie/koa-route');

let app = new Koa();

let items = [];

app.use(KoaRoute.post('/items', async ctx => {
  let item = await KoaBody.json(ctx);
  let itemIndex = items.length;
  items.push(item);
  ctx.body = itemIndex;
}));

app.use(KoaRoute.get('/items/:itemIndex', ctx => {
  let {itemIndex} = ctx.params;
  let item = items[itemIndex];
  ctx.body = JSON.stringify(item);
}));
19.0.1

4 years ago

19.0.0

4 years ago

18.9.27

5 years ago

18.9.26

5 years ago

18.9.25

5 years ago

18.9.24

6 years ago

18.8.9

6 years ago

18.8.8

6 years ago

18.8.7

6 years ago