Gathering detailed insights and metrics for @fastify/accepts-serializer
Gathering detailed insights and metrics for @fastify/accepts-serializer
Gathering detailed insights and metrics for @fastify/accepts-serializer
Gathering detailed insights and metrics for @fastify/accepts-serializer
Serializer according to the accept header
npm install @fastify/accepts-serializer
Typescript
Module System
Node Version
NPM Version
JavaScript (94.52%)
TypeScript (5.48%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
28 Stars
175 Commits
12 Forks
15 Watchers
4 Branches
27 Contributors
Updated on Jun 23, 2025
Latest Version
6.0.2
Package Id
@fastify/accepts-serializer@6.0.2
Unpacked Size
23.72 kB
Size
5.60 kB
File Count
14
NPM Version
10.8.2
Node Version
20.18.0
Published on
Dec 14, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
8
Serialize according to the Accept
header.
1npm i @fastify/accepts-serializer
Plugin version | Fastify version |
---|---|
^6.x | ^5.x |
^5.x | ^4.x |
^3.x | ^3.x |
^2.x | ^2.x |
^1.x | ^1.x |
Please note that if a Fastify version is out of support, then so are the corresponding version(s) of this plugin in the table above. See Fastify's LTS policy for more details.
1 2const protobuf = require('protobufjs') 3const YAML = require('yamljs') 4const msgpack = require('msgpack5')() 5 6const root = protobuf.loadSync('test/awesome.proto') 7const AwesomeMessage = root.lookupType('awesomepackage.AwesomeMessage') 8 9const fastify = require('fastify')() 10 11// Global serializers 12fastify.register(require('@fastify/accepts-serializer'), { 13 serializers: [ 14 { 15 regex: /^application\/yaml$/, 16 serializer: body => YAML.stringify(body) 17 }, 18 { 19 regex: /^application\/x-msgpack$/, 20 serializer: body => msgpack.encode(body) 21 } 22 ], 23 default: 'application/yaml' // MIME type used if Accept header don't match anything 24}) 25 26// Per-router serializers 27const config = { 28 serializers: [ 29 { 30 regex: /^application\/x-protobuf$/, 31 serializer: body => AwesomeMessage.encode(AwesomeMessage.create(body)).finish() 32 } 33 ] 34} 35 36fastify.get('/request', { config }, function (req, reply) { 37 reply.send({pippo: 'pluto'}) 38})
For each route, a SerializerManager is defined, which has both per-route and global serializer definitions.
The MIME type application/json
is always handled by fastify
if no serializer is registered for that MIME type.
If no default
key is specified in configuration, all requests with an unknown Accept
header will be replied to with a 406 response (a boom error is used).
Licensed under MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 3/27 approved changesets -- score normalized to 1
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More