@chainfuse/helpers 2.0.0 → 2.0.1
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/dist/net.d.mts +1 -1
- package/dist/net.mjs +3 -3
- package/package.json +2 -2
package/dist/net.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class NetHelpers {
|
|
|
9
9
|
*/
|
|
10
10
|
static initBodyTrimmer(init?: RequestInit): RequestInit;
|
|
11
11
|
static stripSensitiveHeaders(originalHeaders?: Headers): Headers;
|
|
12
|
-
static cfApi(apiKey: string, cacheStorageRef?:
|
|
12
|
+
static cfApi<C extends CacheStorage>(apiKey: string, cacheStorageRef?: C, cacheTtl?: number, logger?: CustomLoging): Promise<import("cloudflare").Cloudflare>;
|
|
13
13
|
static loggingFetch(info: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1], body?: boolean, logger?: CustomLoging): Promise<Response>;
|
|
14
14
|
/**
|
|
15
15
|
* Parses the Server-Timing header and returns an object with the metrics.
|
package/dist/net.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export class NetHelpers {
|
|
|
18
18
|
originalHeaders.delete('Authorization');
|
|
19
19
|
return originalHeaders;
|
|
20
20
|
}
|
|
21
|
-
static cfApi(apiKey, cacheStorageRef
|
|
21
|
+
static cfApi(apiKey, cacheStorageRef, cacheTtl, logger = false) {
|
|
22
22
|
return import('cloudflare').then(({ Cloudflare }) => new Cloudflare({
|
|
23
23
|
apiToken: apiKey,
|
|
24
24
|
fetch: (info, init) =>
|
|
@@ -38,8 +38,8 @@ export class NetHelpers {
|
|
|
38
38
|
else {
|
|
39
39
|
logger(`CF Fetch request ${cacheKey.url} ${JSON.stringify(this.initBodyTrimmer({ ...init, headers: Object.fromEntries(this.stripSensitiveHeaders(new Headers(init?.headers)).entries()) }), null, '\t')}`);
|
|
40
40
|
}
|
|
41
|
-
if (cacheStorageRef
|
|
42
|
-
const cfCacheRef = cacheStorageRef?.open('cfApi');
|
|
41
|
+
if (cacheStorageRef || cacheTtl) {
|
|
42
|
+
const cfCacheRef = (cacheStorageRef ?? caches)?.open('cfApi');
|
|
43
43
|
if (cfCacheRef) {
|
|
44
44
|
await cfCacheRef
|
|
45
45
|
.then((cfCache) => cfCache
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/helpers",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"@cloudflare/workers-types": "^4.20250303.0",
|
|
59
59
|
"@types/node": "^22.13.9"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "2700804966fc2178ae0e79267f416f813b99ad7b"
|
|
62
62
|
}
|