Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
fastify-protobufjs
Advanced tools
Fastify and protobufjs, together at last. Uses protobufjs by default.
Provides transparent middleware that can be used to support clients requesting Accept: application/x-protobuf from endpoints using res.json or sending Content-Type: application/x-protobufjs to any endpoint. You can continue to use req.body and res.json and fastifyProtobuf will handle the conversion in the background using protobufjs.
$ npm install --save fastify-protobufjs
// or
$ yarn add fastify-protobufjs
$ npm test
const fastifyProtobuf = require("fastify-protobufjs");
// ...
// custom plugin
fastify.register(fastifyProtobuf), {
protoloadPath: path.join(__dirname, 'schema', 'package.proto'),
messagePackage: 'Package'
})
'use strict'
const path = require('path')
const fastify = require('fastify')({
logger: true
})
fastify.register(require('fastify-protobufjs'), {
protoloadPath: path.join(__dirname, 'schema', 'package.proto'),
messagePackage: 'Package'
})
fastify.post('/decode', (req, reply) => {
// http POST http://localhost:5000/decode Accept:application/x-protobuf Content-Type:application/x-protobuf @grpc\package-protobuf.dat
const body = req.body
return body
})
fastify.get('/encode', (req, reply) => {
// http http://localhost:5000/encode Accept:application/x-protobuf
reply.send({
name: "binari-encodings",
private: true,
version: "1.0.0",
main: "index.js",
licence: "MIT",
value: 42
})
})
const start = async () => {
try {
await fastify.listen(5000)
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
}
start()
FAQs
A simple fastify-plugin to serialize binary data to protobuf
We found that fastify-protobufjs 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.