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.
fastify-accepts-serializer
Advanced tools
Serializer according to the Accept
header. Supports Fastify versions >=2.0.0
Please refer to this branch and related versions for Fastify ^1.10.0 compatibility.
npm i --save fastify-accepts-serializer
const protobuf = require('protobufjs')
const YAML = require('yamljs')
const msgpack = require('msgpack5')()
const root = protobuf.loadSync('test/awesome.proto')
const AwesomeMessage = root.lookupType('awesomepackage.AwesomeMessage')
let fastify = require('fastify')()
// Global serializers
fastify.register(require('fastify-accepts-serializer'), {
serializers: [
{
regex: /^application\/yaml$/,
serializer: body => YAML.stringify(body)
},
{
regex: /^application\/x-msgpack$/,
serializer: body => msgpack.encode(body)
}
],
default: 'application/yaml' // mime type used if Accept header don't match anything
})
// Per-router serializers
const config = {
serializer: {
serializers: [
{
regex: /^application\/x-protobuf$/,
serializer: body => AwesomeMessage.encode(AwesomeMessage.create(body)).finish()
}
]
}
}
fastify.get('/request', { config }, function (req, reply) {
reply.send({pippo: 'pluto'})
})
For each route, it's defined a SerilizerManager that has a merge of per-route and global serializers definition.
The mime type application/json
is always handled by fastify
if no serializer is register for that mime type.
If no default
key is specified in configuration, all requests with unknown Accept
header will be replied with an 406 response (a boom error is used)
FAQs
`fastify-accepts-serializer@3.3.0` has been deprecated. Please use `@fastify/accepts-serializer@4.0.0` instead.
The npm package fastify-accepts-serializer receives a total of 39 weekly downloads. As such, fastify-accepts-serializer popularity was classified as not popular.
We found that fastify-accepts-serializer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 17 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.
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.