
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@fastify/any-schema
Advanced tools
Save multiple schemas and decide which one use to serialize the payload Edit
Save multiple schemas and decide which one to use to serialize the payload.
Internally uses fast-json-stringify to compile the schemas in extremely fast serialization functions, with all the benefits given by the library, such as preventing the leaking of sensitive data.
npm i @fastify/any-schema
Register the plugin and pass to it an array of schemas with an id, then use reply.schema(id) to decide which schema to use to serialize your data.
const fastify = require('fastify')()
fastify.register(require('@fastify/any-schema'), {
schemas: [{
$id: 'schema1',
type: 'object',
properties: {
hello: { type: 'string' }
}
}, {
$id: 'schema2',
type: 'object',
properties: {
winter: { type: 'string' }
}
}]
})
fastify.get('/:schema', (req, reply) => {
reply
.schema(req.params.schema)
.send({ hello: 'world' })
})
fastify.listen({ port: 3000 }, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})
This project is kindly sponsored by:
Licensed under MIT.
FAQs
Save multiple schemas and decide which one use to serialize the payload Edit
The npm package @fastify/any-schema receives a total of 27 weekly downloads. As such, @fastify/any-schema popularity was classified as not popular.
We found that @fastify/any-schema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.