Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@keboola/middy-event-validator
Advanced tools
Joi powered event validation middleware for Middy.
The middleware integrates Joi validation library to validate AWS Lambda events triggered by API Gateway.
Failed validations throw error of http-errors
instance with status code 422.
import middy from 'middy';
import eventValidator from '@keboola/middy-event-validator';
export const handler = middy(() => {
// ...
});
handler
.use(eventValidator({
path: {
id: Joi.string().required()
},
body: {
size: Joi.number().integer()
},
pagination: true
}));
The configuration accepts following options:
headers
- validation of HTTP headersbody
- validation of HTTP body in JSON formatpath
- validation of path parameters (shortcut for API Gateway's pathParameters
)query
- validation of query string (shortcut for API Gateway's queryStringParameters
)pagination: true
- shortcut for two query string parameters offset
and limit
validated as numbers.
limit
is 1000. It can be changed by a definition: pagination: { max: 10 }
The module also offers a set of validation shortcuts using class Validation
:
import middy from 'middy';
import eventValidator, { Validation } from '@keboola/middy-event-validator';
handler
.use(eventValidator({
path: {
id: Validation.string('id').required()
}
}));
List of available shortcuts:
getJoi()
- returns Joi instance for custom validationforbidden(param)
- setting of the parameter is forbiddenboolean(param)
- boolean valuestring(param)
- string. All string shortcuts promote trimming of trailing white spacesstringMaxLength(param, length)
- string with maximal lengthinteger(param)
object(param)
enum(param, values)
array(param)
arrayOfStrings(param)
All shortcuts create optional parameters, for required parameters add .required()
.
FAQs
Event validation middleware for Middy
The npm package @keboola/middy-event-validator receives a total of 0 weekly downloads. As such, @keboola/middy-event-validator popularity was classified as not popular.
We found that @keboola/middy-event-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.