params validate middleware of koa base on joi
npm install --save params-validate-feng
const app=require('koa')();
const match=require('url-match-feng');
const validate=require('params-validate-feng');
const Joi =require('joi');
const schema=Joi.object().keys({
id:Joi.string().required()
});
const routesconfig={
'/index': { method: 'GET', cache: 300, main: 'index', type: 'html',schema:schema },
'/channel': { method: 'GET', cache: 200, main: 'channel', type: 'html' },
};
app.use(match({routesConfig}));
app.use(validate());
app.listen(3000);