@lynn123411/dsh-a6api 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/client.js +3 -3
- package/lib/client.js.map +2 -2
- package/lib/index.js +6 -5
- package/lib/index.js.map +2 -2
- package/lib/types/client/store.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1828,8 +1828,8 @@ function createUpstreamMemo(ttlMs, shouldCache) {
|
|
|
1828
1828
|
cache.clear();
|
|
1829
1829
|
inflight.clear();
|
|
1830
1830
|
},
|
|
1831
|
-
async get(key, fetcher) {
|
|
1832
|
-
const hit = cache.get(key);
|
|
1831
|
+
async get(key, fetcher, opts) {
|
|
1832
|
+
const hit = opts?.force ? void 0 : cache.get(key);
|
|
1833
1833
|
if (hit && hit.epoch === epoch && Date.now() - hit.at < ttlMs) return hit.data;
|
|
1834
1834
|
let pending = inflight.get(key);
|
|
1835
1835
|
if (!pending) {
|
|
@@ -1859,8 +1859,8 @@ function stateCacheKeyOf(config) {
|
|
|
1859
1859
|
};
|
|
1860
1860
|
return `${config.baseURL || ""}|${config.userId || ""}|${fingerprint(config.apiKey || "")}|${fingerprint(config.accessToken || "")}`;
|
|
1861
1861
|
}
|
|
1862
|
-
async function getCachedStateResponse(config, configAccess) {
|
|
1863
|
-
return stateMemo.get(stateCacheKeyOf(config), () => buildStateResponse(config, configAccess));
|
|
1862
|
+
async function getCachedStateResponse(config, configAccess, force = false) {
|
|
1863
|
+
return stateMemo.get(stateCacheKeyOf(config), () => buildStateResponse(config, configAccess), { force });
|
|
1864
1864
|
}
|
|
1865
1865
|
async function buildStateResponse(config, configAccess) {
|
|
1866
1866
|
const token = config.accessToken || "";
|
|
@@ -2026,7 +2026,8 @@ function apply(ctx) {
|
|
|
2026
2026
|
try {
|
|
2027
2027
|
if (pathname === "/state" && (req.method === "GET" || req.method === "HEAD")) {
|
|
2028
2028
|
const config = await configAccess.readConfig();
|
|
2029
|
-
const
|
|
2029
|
+
const force = url.searchParams.get("force") === "1";
|
|
2030
|
+
const response = await getCachedStateResponse(config, configAccess, force);
|
|
2030
2031
|
return sendJson(res, 200, { ok: true, data: response });
|
|
2031
2032
|
}
|
|
2032
2033
|
if (pathname === "/config" && req.method === "POST") {
|