koa-cast-joi
Koa casting middleware using Joi.
Usage
const app = const schema = Joiobject // app.use(cast({ 'request.query': schema }))app app
Install
npm install koa-cast-joi joi
Note: Joi is a peer dependency, so it must be installed independently.
API
cast(schemata, [options], [callback])
Cast app.context
by given schemata and options
schemata
is map of paths to coresponding Joi schemasoptions
is passed toJoi.validate
options.context
isapp.context
by default
callback
is passed toJoi.validate
cast.STORE(schema, [options], [callback])
Bind schema to given STORE in following fashion
cast.body
binds toctx.request.body
cast.query
binds toctx.request.query
cast.headers
binds toctx.request.headers
cast.params
binds toctx.params
Related
License
MIT