@molecule/api-resource-message 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":"messages.d.ts","sourceRoot":"","sources":["../../src/handlers/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAK/E;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,IAAI,CAAC,CAwDf;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Df"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/handlers/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAQ/E;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,IAAI,CAAC,CAwDf;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Df"}
@@ -7,6 +7,8 @@ import { t } from '@molecule/api-i18n';
7
7
  import { logger } from '@molecule/api-logger';
8
8
  import { getThreadById, listMessages, sendMessage } from '../service.js';
9
9
  import { sendMessageSchema } from '../validation.js';
10
+ /** Upper bound for the list page size — an uncapped `limit` is a table-dump primitive (e.g. `?limit=999999999`). */
11
+ const MAX_LIST_LIMIT = 500;
10
12
  /**
11
13
  * Lists messages in a thread, newest first.
12
14
  *
@@ -53,7 +55,7 @@ export async function listMessagesHandler(req, res) {
53
55
  return;
54
56
  }
55
57
  const before = typeof req.query.before === 'string' ? req.query.before : undefined;
56
- const limit = parseInt(req.query.limit, 10) || 50;
58
+ const limit = Math.min(MAX_LIST_LIMIT, Math.max(1, parseInt(req.query.limit, 10) || 50));
57
59
  try {
58
60
  const messages = await listMessages(threadId, { before, limit });
59
61
  res.json({ data: messages, limit });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-message",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "1:1 messaging threads + messages with read-tracking and realtime broadcast",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "license": "Apache-2.0",
32
32
  "devDependencies": {
33
- "@molecule/api-locales-resource-message": "1.0.1",
33
+ "@molecule/api-locales-resource-message": "1.0.2",
34
34
  "@types/node": "26.1.2",
35
35
  "typescript": "6.0.3",
36
36
  "vitest": "4.1.11",
@@ -67,7 +67,7 @@
67
67
  "url": "https://github.com/molecule-dev/molecule.git",
68
68
  "directory": "packages/api/resources/message"
69
69
  },
70
- "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/resources/message",
70
+ "homepage": "https://www.molecule.dev/packages/api-resource-message",
71
71
  "bugs": "https://github.com/molecule-dev/molecule/issues",
72
72
  "publishConfig": {
73
73
  "access": "public"