
Research
/Security News
10 npm Typosquatted Packages Deploy Multi-Stage Credential Harvester
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.
fastify-constraints
Advanced tools
fastify-constraintsFastify plugin to add constraints to multiple routes
npm i fastify-constraints
Register fastify-constraints as a Fastify plugin.
The plugin will create an onRoute hook that will add the constraints to the routes.
Contstraints should be specified in the constraints property of the plugin options.
To see available constraints refer to the Fastify documentation.
import Fastify from 'fastify'
import fastifyConstraints from 'fastify-constraints'
const fastify = Fastify()
// Register the plugin
await fastify.register(fastifyConstraints)
// Register plugins containing routes with the constraints
await fastify.register(await (instance, opts) =>
instance.get('/', () => 'Hello from version 1.0.0'), // Add a route
{ constraints: { version: '1.0.0' } }
)
// Start the server
await fastify.listen({ port: 3000 })
You can also specify constraints for specific routes which will be merged:
await fastify.register(fastifyConstraints)
await fastify.register(async (instance, opts) => {
fastify.get('/', () => 'Hello from version 1.0.0') // This route will have the version constraint
fastify.get('/host-restricted', { constraints: { host: 'example.com' } }, () => 'Hello from example.com') // This route will have the version and host constraint
}, {
constraints: { version: '1.0.0' }
})
Note: In case of collision the constraints specified in the route will take precedence over the constraints specified in the plugin options.
See the examples folder for a complete examples.
FAQs
Fastify plugin to add constraints to multiple routes
We found that fastify-constraints demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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 researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.

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.