package
ETag middleware for express.js API compatible routers
npm install tiny-etagGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
72.0 kB
Includes dependencies.
ETag middleware for express.js API compatible routers.
import {etag} from "tiny-etag";
const etags = etag({cacheSize: 500});
const router = SomeRouter(); /* express.js compatible router */
router.use(etags.middleware);
router.get("/", (req, res) => {
const body = "Hello World!";
res.writeHead(200, {"content-type": "text/plain", "etag": etags.create(body)});
res.end(body);
});Tiny ETag has 100% code coverage with its tests.
---------------|---------|----------|---------|---------|---------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|---------------------
All files | 100 | 78.57 | 100 | 100 |
tiny-etag.cjs | 100 | 78.57 | 100 | 100 | 45-49,59,91-109,115
---------------|---------|----------|---------|---------|---------------------Returns an tiny-etag instance. Cache TTL concerns do not spread with a notification.
Creates a strong ETag value from arg; a composite String is recommended. It's ideal to
Creates a hash of arg, uses create()
Returns a boolean if arg should be kept on the cached Object
Middleware to be used by an http framework
Parses arg as a URL if it's a String, or constructs one if it is a socket
Adds url to the cache
Returns a Boolean indicating if caching is valid based on cache-control
Copyright (c) 2023 Jason Mulligan Licensed under the BSD-3 license