@fabrika/app 0.2.0 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/app",
3
- "version": "0.2.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,6 +42,6 @@
42
42
  "test": "bun test"
43
43
  },
44
44
  "dependencies": {
45
- "@fabrika/auth": "^0.2.0"
45
+ "@fabrika/auth": "^0.3.2"
46
46
  }
47
47
  }
package/src/errors.ts CHANGED
@@ -71,6 +71,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {
71
71
  return value !== null && typeof value === 'object'
72
72
  }
73
73
 
74
+ /** True when a thrown value carries its own HTTP status and type, i.e. it is meant to reach the caller as-is. */
75
+ export function isStructuralError(err: unknown): err is StructuralError {
76
+ return isRecord(err)
77
+ && typeof err['httpStatus'] === 'number'
78
+ && typeof err['type'] === 'string'
79
+ && typeof err['message'] === 'string'
80
+ }
81
+
74
82
  /**
75
83
  * Read the structural HTTP-error fields off ANY thrown value. Defaults:
76
84
  * `httpStatus → 500`, `type → 'internal'`, `message → the Error message or 'Internal error'`.
package/src/index.ts CHANGED
@@ -24,7 +24,9 @@ export {
24
24
  defaultOnError,
25
25
  ForbiddenError,
26
26
  HttpError,
27
+ isStructuralError,
27
28
  NotFoundError,
29
+ type StructuralError,
28
30
  toErrorResponse,
29
31
  UnauthorizedError,
30
32
  } from './errors.js'