{"library":"shrink-ray-current","title":"shrink-ray-current: Node.js Compression Middleware","description":"Shrink-ray-current is a Node.js compression middleware designed for Express/Connect applications, providing advanced content encoding capabilities beyond standard gzip. Currently stable at version 4.1.3 (last updated April 2021), it's a maintained fork of the abandoned `shrink-ray` package, ensuring its dependencies are up-to-date. Its key differentiators include built-in support for Brotli and Zopfli (the latter specifically for asynchronous compression of static assets), alongside traditional deflate and gzip. The middleware leverages ETag caching to significantly boost performance for static files, claiming to be 3x faster and using a quarter of the CPU time compared to the standard `compression` middleware in benchmarks, by utilizing higher quality compression algorithms for cached content. Releases appear to be driven by dependency updates or minor bug fixes rather than a fixed schedule.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install shrink-ray-current"],"cli":null},"imports":["const shrinkRay = require('shrink-ray-current');","import shrinkRay from 'shrink-ray-current';","import type { Options } from 'shrink-ray-current';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const express = require('express');\nconst shrinkRay = require('shrink-ray-current');\n\nconst app = express();\n\n// Use the middleware with default options\napp.use(shrinkRay());\n\n// Example route for dynamic content\napp.get('/', (req, res) => {\n  res.send('Hello World! This content will be compressed.');\n});\n\n// Example route for static-like content (e.g., a large JSON file)\napp.get('/data', (req, res) => {\n  const largeData = Array(1000).fill({\n    id: Math.random(),\n    name: 'Item ' + Math.random(),\n    description: 'This is a long description for a test item to ensure compression benefits are visible.',\n    details: {\n      field1: 'value1',\n      field2: 'value2',\n      field3: 'value3',\n      nested: {\n        a: 1,\n        b: 2,\n        c: 3\n      }\n    }\n  });\n  res.json(largeData);\n});\n\n// Start the server\nconst port = process.env.PORT || 3000;\napp.listen(port, () => {\n  console.log(`Server listening on port ${port}`);\n  console.log('Try accessing / and /data with accept-encoding headers (e.g., curl -H \"Accept-Encoding: gzip, deflate, br\" http://localhost:3000/data).');\n});","lang":"javascript","description":"Demonstrates integrating `shrink-ray-current` as Express/Connect middleware for both dynamic and (simulated) static content, showing basic setup and enabling compression for routes.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}