Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@appjumpstart/mercury-schema
Advanced tools
An Express/Connect-compatible middleware for validation and serialization using ajv and fast-json-stringify
An Express/Connect-compatible middleware for validation and serialization using ajv and fast-json-stringify
mercury-schema
is middleware you stick in front of your route handler to
provide 🔥 fast schema validation of the request body and/or automatic
serialization of the handler's response data.
npm install @appjumpstart/mercury-schema --save
NOTE: The example below assumes you're also using the
mercury-send middleware to
stringify the response automatically when calling res.send
.
Add mercury-schema
as a route-level middleware before your route handler and
pass it a schema:
const { mercurySchema } = require('@appjumpstart/mercury-schema')
// ...
app.post('/contact', [
mercurySchema({
request: {
type: 'object',
properties: {
name: { type: 'string' },
email: { type: 'string', minLength: 5 },
message: { type: 'string' }
},
required: ['email', 'message']
},
response: {
type: 'object',
properties: {
message: { type: 'string' }
}
}
}),
function contactHandler (req, res, next) {
try {
if (req.valid) {
sendContactEmail(req.body)
res.send({ message: 'Your message has been sent' })
// Or if, for example, using express without using mercury-send:
// const body = res.stringify({ message: 'Your message has been sent' })
// res.type('json').end(body)
} else {
res.status(400).send(req.validationError)
}
} catch (err) {
next(err)
}
}
])
mercury-schema
is completely modeled around the excellent validation and
serialization feature within the Fastify framework.
FAQs
An Express/Connect-compatible middleware for validation and serialization using ajv and fast-json-stringify
The npm package @appjumpstart/mercury-schema receives a total of 1 weekly downloads. As such, @appjumpstart/mercury-schema popularity was classified as not popular.
We found that @appjumpstart/mercury-schema 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.