@drunkcod/express-kit 0.0.19 → 0.0.20

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.
@@ -1,6 +1,6 @@
1
1
  import type express from 'express';
2
2
  import { Timespan } from './stopwatch.js';
3
- export * from '@drunkcod/express-async';
3
+ export * from 'packages/express-async/lib/index.js';
4
4
  export * from './loggable.js';
5
5
  export * from './stopwatch.js';
6
6
  type AsyncFn<T> = () => Promise<T>;
package/lib/cjs/index.js CHANGED
@@ -19,7 +19,7 @@ exports.onceAsync = onceAsync;
19
19
  exports.mergeCallsAsync = mergeCallsAsync;
20
20
  exports.registerShutdown = registerShutdown;
21
21
  const stopwatch_js_1 = require("./stopwatch.js");
22
- __exportStar(require("@drunkcod/express-async"), exports);
22
+ __exportStar(require("packages/express-async/lib/index.js"), exports);
23
23
  __exportStar(require("./loggable.js"), exports);
24
24
  __exportStar(require("./stopwatch.js"), exports);
25
25
  function onceAsync(fn) {
@@ -26,18 +26,21 @@ function loggableStack(message, stopAt) {
26
26
  message = '';
27
27
  return `LoggableError${message}\n` + s.stack?.substring(6);
28
28
  }
29
- function asLoggableCause(cause) {
29
+ function asLoggableCause(cause, seen = new WeakSet()) {
30
30
  if (cause == null)
31
31
  return null;
32
32
  if (typeof cause !== 'object')
33
33
  return { message: cause };
34
+ if (seen.has(cause))
35
+ return { message: '[Circular Reference]' };
36
+ seen.add(cause);
34
37
  if (hasOwnJSON(cause))
35
- return asLoggableCause(cause.toJSON());
38
+ return asLoggableCause(cause.toJSON(), seen);
36
39
  if (cause instanceof Error || (0, argis_1.hasOwn)(cause, 'cause')) {
37
40
  const { message, stack, cause: innerCause, ...rest } = cause;
38
41
  const r = { message };
39
42
  if (innerCause) {
40
- const loggableInner = asLoggableCause(innerCause);
43
+ const loggableInner = asLoggableCause(innerCause, seen);
41
44
  r.cause = loggableInner;
42
45
  r.message ??= loggableInner.message;
43
46
  }
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type express from 'express';
2
2
  import { Timespan } from './stopwatch.js';
3
- export * from '@drunkcod/express-async';
3
+ export * from 'packages/express-async/lib/index.js';
4
4
  export * from './loggable.js';
5
5
  export * from './stopwatch.js';
6
6
  type AsyncFn<T> = () => Promise<T>;
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Stopwatch } from './stopwatch.js';
2
- export * from '@drunkcod/express-async';
2
+ export * from 'packages/express-async/lib/index.js';
3
3
  export * from './loggable.js';
4
4
  export * from './stopwatch.js';
5
5
  export function onceAsync(fn) {
package/lib/loggable.js CHANGED
@@ -21,18 +21,21 @@ function loggableStack(message, stopAt) {
21
21
  message = '';
22
22
  return `LoggableError${message}\n` + s.stack?.substring(6);
23
23
  }
24
- function asLoggableCause(cause) {
24
+ function asLoggableCause(cause, seen = new WeakSet()) {
25
25
  if (cause == null)
26
26
  return null;
27
27
  if (typeof cause !== 'object')
28
28
  return { message: cause };
29
+ if (seen.has(cause))
30
+ return { message: '[Circular Reference]' };
31
+ seen.add(cause);
29
32
  if (hasOwnJSON(cause))
30
- return asLoggableCause(cause.toJSON());
33
+ return asLoggableCause(cause.toJSON(), seen);
31
34
  if (cause instanceof Error || hasOwn(cause, 'cause')) {
32
35
  const { message, stack, cause: innerCause, ...rest } = cause;
33
36
  const r = { message };
34
37
  if (innerCause) {
35
- const loggableInner = asLoggableCause(innerCause);
38
+ const loggableInner = asLoggableCause(innerCause, seen);
36
39
  r.cause = loggableInner;
37
40
  r.message ??= loggableInner.message;
38
41
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@drunkcod/express-kit",
3
3
  "type": "module",
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "description": "Express4 utility things",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -37,21 +37,21 @@
37
37
  "author": "Tobbe Gyllebring <tobbe@drunkcod.com>",
38
38
  "license": "MIT",
39
39
  "workspaces": [
40
- "express-async"
40
+ "packages/*"
41
41
  ],
42
42
  "dependencies": {
43
- "@drunkcod/argis": "^0.0.13",
43
+ "@drunkcod/argis": "^0.0.14",
44
44
  "@drunkcod/express-async": "^0.0.18"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@drunkcod/ts-jest-esm": "^0.0.3",
48
48
  "@jest/globals": "^30.2.0",
49
- "@types/node": "^24.9.1",
49
+ "@types/node": "^24.10.13",
50
50
  "jest": "^30.2.0",
51
51
  "jest-util": "^30.2.0",
52
52
  "npm-run-all": "^4.1.5",
53
- "rimraf": "^6.0.1",
54
- "ts-jest": "^29.4.5",
53
+ "rimraf": "^6.1.3",
54
+ "ts-jest": "^29.4.6",
55
55
  "typescript": "^5.9.3"
56
56
  }
57
57
  }