@chainfuse/helpers 2.3.0 → 2.3.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.
Files changed (2) hide show
  1. package/dist/net.mjs +11 -4
  2. package/package.json +2 -2
package/dist/net.mjs CHANGED
@@ -23,9 +23,10 @@ export class NetHelpers {
23
23
  apiToken: apiKey,
24
24
  fetch: async (info, init) => {
25
25
  if (typeof logger === 'boolean' && logger) {
26
- logger = (date, id, methodOrStatus, url, headers) => {
26
+ logger = (date, id, methodOrStatus, url, headers, ...rest) => {
27
27
  const customUrl = new URL(url);
28
- const loggingItems = ['CF Rest', date, id, methodOrStatus, `${customUrl.pathname}${customUrl.search}${customUrl.hash}`];
28
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
29
+ const loggingItems = ['CF Rest', date, id, methodOrStatus, `${customUrl.pathname}${customUrl.search}${customUrl.hash}`, ...rest];
29
30
  const customHeaders = new Headers(headers);
30
31
  if (customHeaders.has('cf-ray'))
31
32
  loggingItems.splice(3, 0, customHeaders.get('cf-ray'));
@@ -45,8 +46,14 @@ export class NetHelpers {
45
46
  .then(({ CryptoHelpers }) => CryptoHelpers.base62secret(8))
46
47
  .then(async (id) => {
47
48
  const loggingItems = [new Date().toISOString(), id, init?.method ?? 'GET', this.isRequestLike(info) ? info.url : info.toString(), Object.fromEntries(this.stripSensitiveHeaders(new Headers(init?.headers)).entries())];
48
- if (body)
49
- loggingItems.push(this.initBodyTrimmer(init));
49
+ if (body && init?.body) {
50
+ if (new Headers(init.headers).get('Content-Type')?.toLowerCase().startsWith('application/json')) {
51
+ loggingItems.push(JSON.parse(init?.body));
52
+ }
53
+ else {
54
+ loggingItems.push(init.body);
55
+ }
56
+ }
50
57
  if (typeof logger === 'boolean') {
51
58
  if (logger) {
52
59
  await Promise.all([import('chalk'), import("./index.mjs")])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainfuse/helpers",
3
- "version": "2.3.0",
3
+ "version": "2.3.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.20250407.0",
59
59
  "@types/node": "^22.14.0"
60
60
  },
61
- "gitHead": "bbe7acd905d1ac371a01cbdbcba1fb0023ee185c"
61
+ "gitHead": "7ffca16c4f67ac274f440639b665c3b86da35195"
62
62
  }