
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
fastify-redis-mock
Advanced tools
Fastify Redis mock connection plugin, with this you can share the same Redis mock connection in every part of your server.
This package is useful if you wish to unittest your Fastify project, without the need to run Redis itself.
Full credit goes to the Fastify team for building fastify-redis, and stripsan for building ioredis-mock.
For documentation, please refer to either the Fastify-redis docs, or ioredis-mock docs.
npm i fastify-redis-mock --save
Add it to your project with register
and you are done!
You can access the Redis mock client via fastify.redis
.
const fastify = require('fastify')
const redis = require('fastify-redis')
const redisMock = require('fastify-redis-mock')
// Register the mock for e.g. unit tests
const redisInstance = process.env.ENVIRONMENT === 'unittest' ? redisMock : redis;
fastify.register(redisInstance, [options])
fastify.get('/foo', (req, reply) => {
const { redis } = fastify
redis.get(req.query.key, (err, val) => {
reply.send(err || val)
})
})
fastify.post('/foo', (req, reply) => {
const { redis } = fastify
redis.set(req.body.key, req.body.value, (err) => {
reply.send(err || { status: 'ok' })
})
})
fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})
This project is copied from:
Licensed under MIT.
FAQs
Plugin to share a common Redis mock connection across Fastify.
The npm package fastify-redis-mock receives a total of 1,353 weekly downloads. As such, fastify-redis-mock popularity was classified as popular.
We found that fastify-redis-mock 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.