Closed ghost closed 7 years ago
Not tested, but something like this should work:
const app = require('koa')();
const convert = require('koa-convert');
const body = require('koa-better-body');
app.use(convert(body(options));
The README has info on this.
@andy1028 it works (actually v1 middlewares works currently), but with deprecation messages. The correct and current way is to use koa-convert
as @KevinMartin shown.
I'm thinking to add example using koa-better-router
and instead with koa-router
, cuz it is much much flexible and better.
Actually @KevinMartin example is incorrect.
@andy1028 that is how it looks using koa2
const Koa = require('koa')
const convert = require('koa-convert')
const body = require('koa-better-body')
const app = new Koa()
app.use(convert(body({ some: 'options' })))
app.use(nextV2middleware())
Koa2 requires so much hated calling with new
keyword.
@tunnckoCore I would surely like to see examples with koa-better-router
cause i'm confussed.
I followed your example on koa-better-router
which is using this lib and i got "Not Found" msg whenever i try to reference the route.
https://github.com/tunnckoCore/koa-better-router/tree/master/recipes - don't think to duplicate them here, I invest a lot time in both better-router and rest-router recipes and their readmes.
can provide some example usein koa@2.x?