import { createClient } from 'redis'; import { captureException } from '../../utils/sentry'; export const redisConnectionMiddleware = async (request, response, next) => { try { const redisClient = createClient(); await redisClient.connect(); request.redisClient = redisClient; next(); } catch (error) { captureException(error); next(); } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter