@molecule/api-resource-comment 1.4.0 → 1.4.1

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.
@@ -27,7 +27,7 @@ export async function list(req, res) {
27
27
  return;
28
28
  }
29
29
  const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 20));
30
- const offset = parseInt(req.query.offset, 10) || 0;
30
+ const offset = Math.max(0, parseInt(req.query.offset, 10) || 0);
31
31
  const viewerId = res.locals.session?.userId;
32
32
  try {
33
33
  if (!(await canAccessCommentResource(resourceType, resourceId, 'read', viewerId))) {
@@ -25,7 +25,7 @@ export async function replies(req, res) {
25
25
  return;
26
26
  }
27
27
  const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 20));
28
- const offset = parseInt(req.query.offset, 10) || 0;
28
+ const offset = Math.max(0, parseInt(req.query.offset, 10) || 0);
29
29
  const viewerId = res.locals.session?.userId;
30
30
  try {
31
31
  if (hasResourceAccessPolicies()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-comment",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Threaded comments on any resource with polymorphic attachment, pagination and sequential integer comment numbers (createNumberedComment)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,5 +11,6 @@ CREATE TABLE IF NOT EXISTS "comments" (
11
11
  );
12
12
 
13
13
  CREATE INDEX IF NOT EXISTS "idx_comments_resource" ON "comments" ("resourceType", "resourceId");
14
+ CREATE INDEX IF NOT EXISTS "idx_comments_resource_created" ON "comments" ("resourceType", "resourceId", "createdAt");
14
15
  CREATE INDEX IF NOT EXISTS "idx_comments_parent" ON "comments" ("parentId");
15
16
  CREATE INDEX IF NOT EXISTS "idx_comments_user" ON "comments" ("userId");