Skip to content

🏀 Input & Output validated routing for Express

Notifications You must be signed in to change notification settings

sunkuo/joi-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

joi-router

🏀 Input & Output validated routing for Express

npm version Build Status Coverage Status License: MIT

Todo List

  • ✅ 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

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.

LICENSE

License: MIT

About

🏀 Input & Output validated routing for Express

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages