diff --git a/CHANGELOG.md b/CHANGELOG.md index 429e9c7..c7c7944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # bedrock-manifest-proxy ChangeLog +## 4.1.0 - 2025-05-dd + +### Changed +- Use `lru-cache@11`. + ## 4.0.0 - 2023-10-13 ### Changed diff --git a/lib/http.js b/lib/http.js index 9193cdb..68987f0 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1,15 +1,13 @@ /*! - * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved. */ import * as bedrock from '@bedrock/core'; import {asyncHandler} from '@bedrock/express'; import CachePolicy from 'http-cache-semantics'; import contentType from 'content-type'; -import {createRequire} from 'node:module'; import {httpClient} from '@digitalbazaar/http-client'; import {httpsAgent} from '@bedrock/https-agent'; -const require = createRequire(import.meta.url); -const LRU = require('lru-cache'); +import {LRUCache as LRU} from 'lru-cache'; const {config, util: {BedrockError}} = bedrock; @@ -20,8 +18,8 @@ let MANIFEST_CACHE; bedrock.events.on('bedrock.init', () => { // init web app manifest cache MANIFEST_CACHE = new LRU({ - max: config['manifest-proxy'].manifestCache.size, - length({response}) { + maxSize: config['manifest-proxy'].manifestCache.size, + sizeCalculation({response}) { const headerLength = JSON.stringify(response.headers).length; return headerLength + (response.data ? response.data.length : 0); } @@ -115,7 +113,7 @@ async function getResponse({host}) { // update cache freshUntil = Date.now() + config['manifest-proxy'].manifestCache.ttl; - MANIFEST_CACHE.set(manifestUrl, {policy, response, freshUntil}, ttl); + MANIFEST_CACHE.set(manifestUrl, {policy, response, freshUntil}, {ttl}); // update response header using latest policy response.headers = policy.responseHeaders(); diff --git a/package.json b/package.json index b568b46..4b62d41 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@digitalbazaar/http-client": "^4.0.0", "content-type": "^1.0.4", "http-cache-semantics": "^4.1.0", - "lru-cache": "^6.0.0" + "lru-cache": "^11.1.0" }, "peerDependencies": { "@bedrock/core": "^6.0.0",