Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
express-decorators-joi
Advanced tools
Readme
Defines a middleware function for express-decorators that validates request data using Joi.
$ npm install --save express-decorators-joi
import * as web from 'express-decorators';
import validate from 'express-decorators-joi';
@web.controller('/')
class TestController {
@web.get('/test')
@validate(Joi.object().keys({
name: Joi.string().required(),
birthdate: Joi.date().iso()
}))
testAction(request, response) {
// request.data contains the validated (and converted) data
}
}
It validates request.body
, so you'll need body-parser installed and use
d. If the validation fails, the middleware calls next
with a Joi ValidationError
. You should probably trap this error and return an HTTP 400, e.g.:
app.use(function (err, request, response, next) {
if (err.name === 'ValidationError') {
response.status(400).json({error: err.message});
}
});
That's about it.
ISC, do what you want. All bug reports, issues, comments, suggestions and pull requests welcome.
FAQs
Middleware for express-decorators that validates request body using Joi
The npm package express-decorators-joi receives a total of 2 weekly downloads. As such, express-decorators-joi popularity was classified as not popular.
We found that express-decorators-joi 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.