joi-router
v0.0.9
Published
Input & Output validated routing for Express
Downloads
14
Readme
joi-router
:basketball: Input & Output validated routing for Express
Todo List
- :white_check_mark: Input Validated Routing
- :white_check_mark: Output Validated Routing
- :white_check_mark: Examples to show how to use joi-router
- :white_check_mark: Self-contained Test
- :white_check_mark: Continuous integration
- :white_check_mark: Code coverage
- :ballot_box_with_check: Joi-router to documents
How to install
yarn add joi-router
Get Started
Input Validaiton
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'
})
})
Output Validation
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!')
})
Node compatibility
NodeJS >= 6.0
is required.
Performance
Joi-router only run once to add validation middleware when express start, so it does not make express slow.