🏀 Input & Output validated routing for Express
- ✅ Input Validated Routing
- ✅ Output Validated Routing
- ✅ Examples to show how to use joi-router
- ✅ Self-contained Test
- ✅ Continuous integration
- ✅ Code coverage
- ☑️ Joi-router to api documents
yarn add joi-router
const express = require('express')
const Joi = require('joi')
require('joi-router')
const app = express()
app.get('/foo', {query: {
userId: Joi.string().alphanum().min(3).max(30).required()
}}, function (req, res, next) {
res.json({
result: 'success'
})
})
app.get('/foo', {
output: {
'200': { content: Joi.string().alphanum().min(3).max(30).required() }
}
}, function (req, res, next) {
res.json({
content: 'Lorem'
})
})
app.listen(3000, () => {
console.log('Server Run!')
})
NodeJS >= 6.0
is required.
Joi-router only run once to add validation middleware when express start, so it does not make express slow.