@random-guys/express-joi
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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({})
})

Readme

Keywords

none

Package Sidebar

Install

npm i @random-guys/express-joi

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

176 kB

Total Files

10

Last publish

Collaborators

  • random-guys