I'm using koa-joi-validator
in KOA js.
JOI validation works properly for GET
method. But when POST
method triggers it just receives the request and that's it, No validation triggered, No response sent.
GET
<-- GET /user/1
--> GET /user/1 200 107ms 4b
POST
<-- POST /create
If i remove JOI validation from POST request, then the route works fine.
app.js
var bodyparser = require('koa-bodyparser')
app.use(bodyparser())
routes.js
var validator = require('koa-joi-validator')
route.get('/user/:userid', validator.validate({
type: 'json',
params: { userid: validator.Joi.string().required() }
}, function *() { this.body = 'test' })
route.post('/create', validator.validate({
type: 'json',
body: { username: validator.Joi.string().required() }
}), function *() { this.body = 'test' })