@random-guys/express-joi
v0.1.0
Published
Wrapper around axios for interservice communication
Downloads
2
Readme
express-joi
Express middleware for joi
How to install?
yarn add @random-guys/express-joi
How does it work?
Validate body of POST
requests
import { refreshJSend } from "@random-guys/express-jsend";
// make use to use the jsend middleware
app.use(refreshJSend)
const schema = joi.object({
name: joi.string().required(),
age: joi.number().required()
})
app.post('/endpoint', validate(schema), (_req, res) => {
res.status(200).json({})
})
or GET
queries
const schem = joi.object({
canType: joi.bool(),
age: joi.number()
})
app.get('/query', validate(schem, 'query'), (_req, res) => {
res.status(200).json({})
})