UNPKG

lru-send

Version:

LRU-based caching middleware for Node.js

76 lines 3.45 kB
{ "name": "lru-send", "version": "0.1.3", "description": "LRU-based caching middleware for Node.js", "type": "module", "exports": { ".": "./dist/index.js", "./redis": "./dist/redis.js" }, "types": "./dist/index.d.ts", "files": [ "dist" ], "repository": { "type": "git", "url": "git+https://github.com/tinyhttp/lru-send.git" }, "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "keywords": [ "http", "tinyhttp", "response-caching", "cache", "perf", "lru", "performance" ], "author": "v1rtl", "license": "MIT", "bugs": { "url": "https://github.com/tinyhttp/lru-send/issues" }, "homepage": "https://github.com/tinyhttp/lru-send#readme", "funding": { "type": "individual", "url": "https://github.com/talentlessguy/better-schema-link?sponsor=1" }, "devDependencies": { "@commitlint/cli": "16.2.1", "@commitlint/config-conventional": "16.2.1", "@rollup/plugin-typescript": "^8.3.1", "@tinyhttp/app": "^2.0.19", "@types/ioredis": "^4.28.8", "@types/node": "^17.0.21", "@typescript-eslint/eslint-plugin": "5.13.0", "@typescript-eslint/parser": "5.13.0", "c8": "7.11.0", "eslint": "8.10.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-prettier": "4.0.0", "husky": "7.0.4", "prettier": "^2.5.1", "rollup": "^2.69.1", "supertest-fetch": "^1.5.0", "tsm": "^2.2.1", "typescript": "^4.6.2", "uvu": "^0.5.3" }, "dependencies": { "quick-lru": "^6.1.0" }, "optionalDependencies": { "ioredis": "^4.28.5" }, "scripts": { "build": "rollup -c", "test": "tsm node_modules/uvu/bin.js tests", "test:coverage": "c8 --include=src pnpm test", "test:report": "c8 report --reporter=text-lcov > coverage.lcov", "lint": "eslint \"./**/*.ts\"", "format": "prettier --write \"./**/*.ts\"" }, "readme": "<div align=\"center\">\n\n# lru-send\n\n[![npm][npm-img]][npm-url] [![GitHub Workflow Status][actions-badge]][github-actions] [![Coverage][cov-img]][cov-url]\n\n</div>\n\nLRU-based caching middleware for Node.js that patches `res.send`.\n\n## Features\n\n- 😲 [**~336x faster**](bench) for heavy operations\n- ⚡ ESM-only\n- ✨ types out of the box\n- 🟥 (optionally) supports [Redis](http://redis.io/)\n\n## Install\n\n```sh\npnpm i lru-send\n```\n\n## Examples\n\n### In-memory\n\n```ts\nimport { lruSend } from 'lru-send'\nimport { App } from '@tinyhttp/app'\n\nconst app = new App()\n\napp.use(lruSend())\n\napp.use('/', (_req, res) => {\n someUltraHeavyOp()\n res.send('hello')\n})\n\napp.listen(3000)\n```\n\n### Redis\n\n```ts\nimport { lruSend } from 'lru-send/redis'\nimport { App } from '@tinyhttp/app'\nimport Redis from 'ioredis'\n\nconst redis = new Redis()\n\nconst app = new App()\n\napp.use(lruSend(redis))\n\napp.use('/', (_req, res) => {\n someUltraHeavyOp()\n res.send('hello')\n})\n\napp.listen(3000)\n```\n\n[npm-url]: https://npmjs.com/package/lru-send\n[github-actions]: https://github.com/tinyhttp/lru-send/actions\n[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/lru-send?style=for-the-badge&color=9F5E8C\n[cov-url]: https://coveralls.io/github/tinyhttp/lru-send\n[npm-img]: https://img.shields.io/npm/dt/lru-send?style=for-the-badge&color=9F5E8C\n[actions-badge]: https://img.shields.io/github/workflow/status/tinyhttp/lru-send/CI?style=for-the-badge&logo=github&label=&color=9F5E8C\n" }