Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
joi-express
Advanced tools
Simple validation middleware for express using the joi validation suite.
Simple validation middleware for express using the Joi validation suite.
npm install joi-express
npm install joi
var Express = require('express');
var BodyParser = require('body-parser');
var ExpressJoi = require('joi-express');
var Joi = require('joi');
var app = Express();
app.use(BodyParser.json());
// Use Joi to create your schemas
var querySchema = {
query: {
limit: Joi.number().default(10).min(10).max(100),
offset: Joi.number().default(10).min(10).max(100)
},
headers: {
authorization: Joi.string().required()
}
};
// Attach the validator like other middleware
app.get('/', expressJoi(querySchema), function (req, res, next) {
// do something with req.query.limit & req.query.offset
...
});
// Use Joi to create your schemas
var bodySchema = {
body: {
name: Joi.string().required()
}
};
// Attach the validator like other middleware
app.post('/', expressJoi(bodySchema), function (req, res, next) {
// do something with req.body;
...
});
// Example error handler
app.use(function (err, req, res, next) {
if (err.isBoom) {
return res.status(err.output.statusCode).json(err.output.payload);
}
});
app.listen(8080);
If a validation error occurs it will either be handled by your express error handling middleware or thrown.
Since this middleware is just a wrapper around the Joi validate
method all the options
are supported.
npm install
npm test
FAQs
Simple validation middleware for express using the joi validation suite.
The npm package joi-express receives a total of 2 weekly downloads. As such, joi-express popularity was classified as not popular.
We found that joi-express demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.