@molecule/api-resource-user 1.5.4 → 1.5.5

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 CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-16T15:44:04.216Z
6
+ Generated: 2026-10-16T20:59:27.799Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-user
@@ -37,6 +37,20 @@ emailed-token reset). To read or write one secret yourself, use the abstract dat
37
37
  same key — `findById('usersSecrets', userId)`, or `${tableName}Secrets` when the resource
38
38
  carries a custom `tableName` — never SQL.
39
39
 
40
+ **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
41
+ `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
42
+ for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
43
+ `res.send(body)`); calling a handler directly is only correct if you apply the result yourself:
44
+
45
+ ```typescript
46
+ const { statusCode, headers, body } = await handlers.logIn(resource)(req, res)
47
+ if (headers) res.set(headers)
48
+ res.status(statusCode).send(body)
49
+ ```
50
+
51
+ Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
52
+ produces, so the request it was meant to answer is left unanswered and hangs.
53
+
40
54
  ## Quick Start
41
55
 
42
56
  ```ts
package/dist/index.d.ts CHANGED
@@ -23,6 +23,20 @@
23
23
  * same key — `findById('usersSecrets', userId)`, or `${tableName}Secrets` when the resource
24
24
  * carries a custom `tableName` — never SQL.
25
25
  *
26
+ * **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
27
+ * `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
28
+ * for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
29
+ * `res.send(body)`); calling a handler directly is only correct if you apply the result yourself:
30
+ *
31
+ * ```typescript
32
+ * const { statusCode, headers, body } = await handlers.logIn(resource)(req, res)
33
+ * if (headers) res.set(headers)
34
+ * res.status(statusCode).send(body)
35
+ * ```
36
+ *
37
+ * Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
38
+ * produces, so the request it was meant to answer is left unanswered and hangs.
39
+ *
26
40
  * @remarks
27
41
  * The user record is split across TWO schemas — pick the right one or you leak credentials:
28
42
  * - **{@link Props} (`propsSchema`)** — SAFE, client-facing fields (username, name, email,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6JG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
package/dist/index.js CHANGED
@@ -23,6 +23,20 @@
23
23
  * same key — `findById('usersSecrets', userId)`, or `${tableName}Secrets` when the resource
24
24
  * carries a custom `tableName` — never SQL.
25
25
  *
26
+ * **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
27
+ * `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
28
+ * for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
29
+ * `res.send(body)`); calling a handler directly is only correct if you apply the result yourself:
30
+ *
31
+ * ```typescript
32
+ * const { statusCode, headers, body } = await handlers.logIn(resource)(req, res)
33
+ * if (headers) res.set(headers)
34
+ * res.status(statusCode).send(body)
35
+ * ```
36
+ *
37
+ * Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
38
+ * produces, so the request it was meant to answer is left unanswered and hangs.
39
+ *
26
40
  * @remarks
27
41
  * The user record is split across TWO schemas — pick the right one or you leak credentials:
28
42
  * - **{@link Props} (`propsSchema`)** — SAFE, client-facing fields (username, name, email,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-user",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "User resource types and schema for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",