@molecule/api-resource-comment 1.0.2 → 1.0.4
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":"replies.d.ts","sourceRoot":"","sources":["../../src/handlers/replies.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"replies.d.ts","sourceRoot":"","sources":["../../src/handlers/replies.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAO/E;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBxF"}
|
package/dist/handlers/replies.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { t } from '@molecule/api-i18n';
|
|
7
7
|
import { logger } from '@molecule/api-logger';
|
|
8
8
|
import { getReplies } 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 replies to a comment.
|
|
11
13
|
*
|
|
@@ -21,7 +23,7 @@ export async function replies(req, res) {
|
|
|
21
23
|
});
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
|
-
const limit = parseInt(req.query.limit, 10) || 20;
|
|
26
|
+
const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 20));
|
|
25
27
|
const offset = parseInt(req.query.offset, 10) || 0;
|
|
26
28
|
try {
|
|
27
29
|
const result = await getReplies(commentId, { limit, offset });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-resource-comment",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Threaded comments on any resource with polymorphic attachment and pagination",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -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://
|
|
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"
|