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
npm install @fastify/accepts-serializer
Typescript
Module System
Node Version
NPM Version
76
Supply Chain
94
Quality
88.3
Maintenance
100
Vulnerability
100
License
JavaScript (94.52%)
TypeScript (5.48%)
Total Downloads
67,948
Last Day
323
Last Week
1,480
Last Month
5,323
Last Year
36,265
28 Stars
169 Commits
12 Forks
17 Watching
4 Branches
27 Contributors
Minified
Minified + Gzipped
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
Publised On
14 Dec 2024
Cumulative downloads
Total Downloads
Last day
1.3%
323
Compared to previous day
Last week
3.9%
1,480
Compared to previous week
Last month
13.1%
5,323
Compared to previous month
Last year
84.5%
36,265
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
no dangerous workflow patterns detected
Reason
18 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
Found 4/25 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-01-27
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