{"_id":"@bogeychan/elysia-etag","_rev":"6-aa24e82db8839bc3ba368ba1a810f188","name":"@bogeychan/elysia-etag","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@bogeychan/elysia-etag","version":"0.0.1","keywords":["elysia","etag"],"author":{"url":"https://github.com/bogeychan","name":"bogeychan","email":"bogeychan@outlook.com"},"license":"MIT","_id":"@bogeychan/elysia-etag@0.0.1","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"dist":{"shasum":"0eed740dee2b7669f7b0b83432be137b9b89e796","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.0.1.tgz","fileCount":12,"integrity":"sha512-wXwryS8ByvCBc9gSf5ewAbxAtuvawl35LC7qNRgWmxs24+MjqExiyNl8ko2t9iotCHq4oLjh7RtPVE0Bk/dpOQ==","signatures":[{"sig":"MEUCIEVPnzPqKBvRFsnjF9Uz/ovg67kDGv3cydJOEXOHRjznAiEAj/HuhIeZ9wt/8G7IVa/m79C9+A6q3uol5OT9bDbnHkk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12780},"main":"./dist/index.js","type":"module","types":"./src/index.ts","exports":{"node":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.js"},"gitHead":"f108848aa0815b68d871474d16e487b59128bb5b","scripts":{"dev":"bun run --watch examples/basic/index.ts","test":"bun test","build":"rm -fr dist && tsc --project tsconfig.esm.json","release":"npm run build && npm run test && npm publish --access public"},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"repository":{"url":"git+https://github.com/bogeychan/elysia-etag.git","type":"git"},"_npmVersion":"9.5.1","description":"A plugin for Elysia.js for ETag","directories":{},"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"devDependencies":{"elysia":"^0.6.19","bun-types":"^1.0.1","typescript":"^5.2.2"},"peerDependencies":{"elysia":">= 0.6.19"},"_npmOperationalInternal":{"tmp":"tmp/elysia-etag_0.0.1_1694299154467_0.9916195368435741","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@bogeychan/elysia-etag","version":"0.0.2","keywords":["elysia","etag"],"author":{"url":"https://github.com/bogeychan","name":"bogeychan","email":"bogeychan@outlook.com"},"license":"MIT","_id":"@bogeychan/elysia-etag@0.0.2","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"dist":{"shasum":"b1ee8879671fc22e4faaa8c8c62ab762499d9081","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.0.2.tgz","fileCount":12,"integrity":"sha512-Zd7AoL8mA9lMva8yJQkU4lW4hVlNCG3Wgefmz5TTtbK4Zzv3EV3xI2I7I/FEEHUYQmX6YgY1jOzWCOUUccQrLw==","signatures":[{"sig":"MEUCIQCQ9/gsDZvREd41qZBpTDTwT1J+I/EqZKI1o7owuT03fwIgLZO6qHt4XfZaYMT4cdoNtVYeYVdsFgJ0b71uxqpx0z8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12894},"main":"./dist/index.js","type":"module","types":"./src/index.ts","exports":{"node":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.js"},"gitHead":"61d350fe9b51912cea56f7ce67b030437dafa060","scripts":{"dev":"bun run --watch examples/basic/index.ts","test":"bun test","build":"rm -fr dist && tsc --project tsconfig.esm.json","release":"npm run build && npm run test && npm publish --access public"},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"repository":{"url":"git+https://github.com/bogeychan/elysia-etag.git","type":"git"},"_npmVersion":"9.5.1","description":"A plugin for Elysia.js for automatic HTTP ETag generation","directories":{},"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"devDependencies":{"elysia":"^0.6.19","bun-types":"^1.0.1","typescript":"^5.2.2"},"peerDependencies":{"elysia":">= 0.6.19"},"_npmOperationalInternal":{"tmp":"tmp/elysia-etag_0.0.2_1694301322070_0.01330575435354353","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@bogeychan/elysia-etag","version":"0.0.3","keywords":["elysia","etag"],"author":{"url":"https://github.com/bogeychan","name":"bogeychan","email":"bogeychan@outlook.com"},"license":"MIT","_id":"@bogeychan/elysia-etag@0.0.3","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"dist":{"shasum":"65ad86366a9eef9dc2c6878ea45aa16a19406a75","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.0.3.tgz","fileCount":12,"integrity":"sha512-eP2enUKkTwEqAsOEq8uDrnq7/oQWVqMPiEE17Za8G33Dz21eta9GXS18sVfdhHhoETDBnf8vvRvgZQOVi6Rt7A==","signatures":[{"sig":"MEUCIDTJU1+ZIeigGPh7RCstZSz8nbfXkYDfiV4SHYQamzTrAiEAi54F/H2un+ytMuYPVlPdOs+SYp4+tYzvt3Ov1TMgpGQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12339},"main":"./dist/index.js","type":"module","types":"./src/index.ts","exports":{"node":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.js"},"gitHead":"ad4b5e6432faca21e1d4447deccffc297afb8f99","scripts":{"dev":"bun run --watch examples/basic.ts","test":"bun test","build":"rm -fr dist && tsc --project tsconfig.esm.json","release":"npm run build && npm run test && npm publish --access public"},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"repository":{"url":"git+https://github.com/bogeychan/elysia-etag.git","type":"git"},"_npmVersion":"9.5.1","description":"A plugin for Elysia.js for automatic HTTP ETag generation","directories":{},"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"devDependencies":{"elysia":"^0.7.15","bun-types":"^1.0.4","typescript":"^5.2.2"},"peerDependencies":{"elysia":">= 0.7.15"},"_npmOperationalInternal":{"tmp":"tmp/elysia-etag_0.0.3_1696351326917_0.0054161767429796726","host":"s3://npm-registry-packages"}},"0.0.4":{"name":"@bogeychan/elysia-etag","version":"0.0.4","keywords":["elysia","etag"],"author":{"url":"https://github.com/bogeychan","name":"bogeychan","email":"bogeychan@outlook.com"},"license":"MIT","_id":"@bogeychan/elysia-etag@0.0.4","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"dist":{"shasum":"16837f36cc066e1e4c81dfa0268fa23e6a903f87","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.0.4.tgz","fileCount":12,"integrity":"sha512-lcZFJoKGbwMOHiJ76Ge7z0lLxP6EPvrQoLPY1vcg8Rx7BS6ahjbmTsov5RZvL0AMpgK3v9hOyN6c2KnrqkjDgA==","signatures":[{"sig":"MEUCIH9+zuZq2O1qPGxpGgXpyLbauso06w5brOVcT82WVFY6AiEAppHsRP1lWWcUmmyngGDzLWQZRRQEPcHrMqlT8Qrh9Vc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12404},"main":"./dist/index.js","type":"module","types":"./src/index.ts","exports":{"node":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.js"},"gitHead":"7f9b01f3166a339b4edb8fc32427de3069f7cccc","scripts":{"dev":"bun run --watch examples/basic.ts","test":"bun test","build":"rm -fr dist && tsc --project tsconfig.esm.json","release":"npm run build && npm run test && npm publish --access public"},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"repository":{"url":"git+https://github.com/bogeychan/elysia-etag.git","type":"git"},"_npmVersion":"10.2.5","description":"A plugin for Elysia.js for automatic HTTP ETag generation","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"elysia":"^0.8.3","bun-types":"1","typescript":"5"},"peerDependencies":{"elysia":">= 0.8.3"},"_npmOperationalInternal":{"tmp":"tmp/elysia-etag_0.0.4_1703432552873_0.4897194259844233","host":"s3://npm-registry-packages"}},"0.0.5":{"name":"@bogeychan/elysia-etag","version":"0.0.5","keywords":["elysia","etag"],"author":{"url":"https://github.com/bogeychan","name":"bogeychan","email":"bogeychan@outlook.com"},"license":"MIT","_id":"@bogeychan/elysia-etag@0.0.5","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"dist":{"shasum":"326a59d7247d32d0dc38c124e56008e9433997e2","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.0.5.tgz","fileCount":12,"integrity":"sha512-mUsmaMOqPl0QIAdZ+1g5B8NZJUsOFvXz4C7RRaW3jIoY8qVZzXTciFjcyLec4goNPQ+N+4oRYRcjXyeTb8Wixg==","signatures":[{"sig":"MEYCIQDC//a6g94sVXpTbc1bvLaJ+FMwZUPYsMuzlnb13cPBlAIhAJUogmWoGiBScy+lxYeHDt1eRBliOkNfmTKfsts28RBK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12439},"main":"./dist/index.js","type":"module","types":"./src/index.ts","exports":{"node":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.js"},"gitHead":"3d4ebcce112fad94489bb159a30474bddbc60731","scripts":{"dev":"bun run --watch examples/basic.ts","test":"bun test","build":"rm -fr dist && tsc --project tsconfig.esm.json","release":"npm run build && npm run test && npm publish --access public"},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"repository":{"url":"git+https://github.com/bogeychan/elysia-etag.git","type":"git"},"_npmVersion":"10.2.5","description":"A plugin for Elysia.js for automatic HTTP ETag generation","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"elysia":"^0.8.16","@types/bun":"1","typescript":"5"},"peerDependencies":{"elysia":">= 0.8.16"},"_npmOperationalInternal":{"tmp":"tmp/elysia-etag_0.0.5_1707309511016_0.5073222534377204","host":"s3://npm-registry-packages"}},"0.0.6":{"name":"@bogeychan/elysia-etag","version":"0.0.6","keywords":["elysia","etag"],"author":{"url":"https://github.com/bogeychan","name":"bogeychan","email":"bogeychan@outlook.com"},"license":"MIT","_id":"@bogeychan/elysia-etag@0.0.6","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"dist":{"shasum":"3ff0ec4e88ef196fe56d0947088f9ce4697a34eb","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.0.6.tgz","fileCount":13,"integrity":"sha512-DPHRQJLm4mR5zkQk+DYhDEX1YFh0S5M3ZTqLy/SJ+kdT68c3wxynkyZZtL2YRNhZ0LKHuDXzqAXd77eTZeKxMg==","signatures":[{"sig":"MEQCIDtaTStDXmhPdR0akZT5z6bY21CTM+E5Zjy8RT6XEdcgAiBtHtYRXoHORYTS6TmNZRYkYP268eqGbPnL9eIjcG4SRA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12335},"main":"./dist/index.js","type":"module","types":"./src/index.ts","exports":{"node":"./dist/index.js","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.js"},"gitHead":"c9246a57a09eac53d4b85a3ea1a6ab00b8c6c450","scripts":{"dev":"bun run --watch examples/basic.ts","test":"bun test","build":"rm -fr dist && tsc --project tsconfig.esm.json","release":"npm run build && npm run test && npm publish --access public"},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"repository":{"url":"git+https://github.com/bogeychan/elysia-etag.git","type":"git"},"_npmVersion":"10.2.5","description":"A plugin for Elysia.js for automatic HTTP ETag generation","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"elysia":"^1.0.22","@types/bun":"1","typescript":"5"},"peerDependencies":{"elysia":">= 1.0.22"},"_npmOperationalInternal":{"tmp":"tmp/elysia-etag_0.0.6_1716667367920_0.7690021082241596","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"@bogeychan/elysia-etag","version":"0.1.0","description":"A plugin for Elysia.js for automatic HTTP ETag generation","author":{"name":"bogeychan","email":"bogeychan@outlook.com","url":"https://github.com/bogeychan"},"repository":{"type":"git","url":"git+https://github.com/bogeychan/elysia-etag.git"},"type":"module","main":"./dist/index.js","exports":"./dist/index.js","types":"./src/index.ts","scripts":{"dev":"bun run --watch examples/basic.ts","test":"bun test","build":"bun run ./build.ts","release":"npm run build && npm run test && npm publish --access public"},"peerDependencies":{"elysia":">= 1.2.10"},"devDependencies":{"@types/bun":"^1.2.0","elysia":"^1.2.10","typescript":"^5.7.3"},"homepage":"https://github.com/bogeychan/elysia-etag","bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"license":"MIT","keywords":["elysia","etag"],"_id":"@bogeychan/elysia-etag@0.1.0","gitHead":"bd6c1b07d5984a01a0634bca17f8cd6b7d6fbfa4","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-wKRt7I1AYew+Xem5dSSIIuRwr/MRpWa5qWC9CQIq5NKYVI0TvZciWQArKG/MMJ0ibfyFouKETTernU8vY+bYEQ==","shasum":"4408611de3285a0f956915c8bcf61ba623b8d673","tarball":"https://registry.npmjs.org/@bogeychan/elysia-etag/-/elysia-etag-0.1.0.tgz","fileCount":14,"unpackedSize":16685,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDjamQmTB5zptspyiBMR/daaxcQ07b7fNbULW8DcCKqTgIgVaTJpukTzuHRb19jL9or9PEEh46PoNBCfWhcLYubQS8="}]},"_npmUser":{"name":"bogeychan","email":"bogeychan@outlook.com"},"directories":{},"maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/elysia-etag_0.1.0_1737933935640_0.9347266620476755"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-09T22:39:14.363Z","modified":"2025-01-26T23:25:36.014Z","0.0.1":"2023-09-09T22:39:14.679Z","0.0.2":"2023-09-09T23:15:22.243Z","0.0.3":"2023-10-03T16:42:07.105Z","0.0.4":"2023-12-24T15:42:33.053Z","0.0.5":"2024-02-07T12:38:31.166Z","0.0.6":"2024-05-25T20:02:48.085Z","0.1.0":"2025-01-26T23:25:35.817Z"},"bugs":{"url":"https://github.com/bogeychan/elysia-etag/issues"},"author":{"name":"bogeychan","email":"bogeychan@outlook.com","url":"https://github.com/bogeychan"},"license":"MIT","homepage":"https://github.com/bogeychan/elysia-etag","keywords":["elysia","etag"],"repository":{"type":"git","url":"git+https://github.com/bogeychan/elysia-etag.git"},"description":"A plugin for Elysia.js for automatic HTTP ETag generation","maintainers":[{"name":"bogeychan","email":"bogeychan@outlook.com"}],"readme":"# @bogeychan/elysia-etag\r\n\r\nA plugin for [Elysia.js](https://elysiajs.com) for automatic [HTTP ETag](https://http.dev/etag) generation\r\n\r\n## Installation\r\n\r\n```bash\r\nbun add @bogeychan/elysia-etag\r\n```\r\n\r\n## Usage\r\n\r\n```ts\r\nimport { Elysia } from 'elysia'\r\nimport { etag } from '@bogeychan/elysia-etag'\r\n\r\nconst app = new Elysia()\r\n\t.use(etag())\r\n\t.get('/', () => 'Checkout the response headers!')\r\n\t.get('/custom-etag', (ctx) => {\r\n\t\t// This line disables automatic ETag generation\r\n\t\t// It will still return a 304 - Not Modified - status code if the ETag matches\r\n\t\tctx.setETag('\"myETag\"')\r\n\t\treturn 'Hello ETag!'\r\n\t})\r\n\t.listen(3000)\r\n\r\nconsole.log(`Listening on ${app.server!.url}`)\r\n```\r\n\r\n### Use `serialize` to convert incompatible data to a hashable format\r\n\r\n#### With JSON\r\n\r\n```ts\r\nnew Elysia()\r\n\t.use(\r\n\t\tetag({\r\n\t\t\tserialize(response) {\r\n\t\t\t\tif (typeof response === 'object') {\r\n\t\t\t\t\treturn JSON.stringify(response)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t)\r\n\t.get('/', () => ({ my: 'json' }))\r\n```\r\n\r\n#### With [BunFile](https://bun.sh/docs/api/file-io)\r\n\r\n```ts\r\nnew Elysia()\r\n\t.use(\r\n\t\tetag({\r\n\t\t\tserialize(response) {\r\n\t\t\t\tif (response instanceof Blob && 'lastModified' in response) {\r\n\t\t\t\t\t// based on last modified UNIX timestamp\r\n\t\t\t\t\treturn (response as BunFile).lastModified.toString()\r\n\r\n\t\t\t\t\t// based on file content\r\n\t\t\t\t\treturn (response as BunFile).bytes()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t)\r\n\t.get('/', () => Bun.file('./file.txt'))\r\n```\r\n\r\n### Provide your own `hash` function\r\n\r\n```ts\r\nlet myInsecureChangeCounter = 0\r\n\r\nnew Elysia()\r\n\t.use(\r\n\t\tetag({\r\n\t\t\thash: (response) => {\r\n\t\t\t\treturn (response as string) + myInsecureChangeCounter++\r\n\t\t\t}\r\n\t\t})\r\n\t)\r\n\t.get('/', () => 'Checkout the response headers!')\r\n```\r\n\r\nCheckout the [examples](./examples) folder on github for further use cases.\r\n\r\n## Credits ❤️\r\n\r\nThis project was inspired by [@fastify/etag](https://www.npmjs.com/package/@fastify/etag)\r\n\r\n## Author\r\n\r\n[bogeychan](https://github.com/bogeychan)\r\n\r\n## License\r\n\r\n[MIT](LICENSE)\r\n\r\n```\r\n\r\n```\r\n","readmeFilename":"README.md"}