@molecule/api-resource-comment 1.0.1 → 1.0.3

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 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/handlers/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAI/E;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BrF"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/handlers/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAO/E;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BrF"}
@@ -6,6 +6,8 @@
6
6
  import { t } from '@molecule/api-i18n';
7
7
  import { logger } from '@molecule/api-logger';
8
8
  import { getCommentsByResource } from '../service.js';
9
+ /** Upper bound for the list page size — an uncapped `limit` is a table-dump primitive (e.g. `?limit=999999999`). */
10
+ const MAX_LIST_LIMIT = 500;
9
11
  /**
10
12
  * Lists paginated top-level comments for a resource.
11
13
  *
@@ -23,7 +25,7 @@ export async function list(req, res) {
23
25
  });
24
26
  return;
25
27
  }
26
- const limit = parseInt(req.query.limit, 10) || 20;
28
+ const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 20));
27
29
  const offset = parseInt(req.query.offset, 10) || 0;
28
30
  try {
29
31
  const result = await getCommentsByResource(resourceType, resourceId, { limit, offset });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-comment",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Threaded comments on any resource with polymorphic attachment and pagination",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@types/node": "26.1.2",
32
32
  "typescript": "6.0.3",
33
- "vitest": "4.1.10",
33
+ "vitest": "4.1.11",
34
34
  "zod": "4.4.3"
35
35
  },
36
36
  "peerDependencies": {
@@ -59,7 +59,7 @@
59
59
  "url": "https://github.com/molecule-dev/molecule.git",
60
60
  "directory": "packages/api/resources/comment"
61
61
  },
62
- "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/resources/comment",
62
+ "homepage": "https://www.molecule.dev/packages/api-resource-comment",
63
63
  "bugs": "https://github.com/molecule-dev/molecule/issues",
64
64
  "publishConfig": {
65
65
  "access": "public"