collabcentral/package.json
Joseph B. McQueen 2b37c4b24f Phase 8: extract pure helpers into lib/ and cover with node:test
- Move buildingKey, jobsForApp, getBotToken, isBotEnabled, getBotConfig,
  isAuthorized, getOAuthRedirectUri, buildAuthUrl, cleanCompletedJobs,
  and msToTime into lib/helpers.js as state-free functions that accept
  config, botTokens, or env as parameters. COMPLETED_RETENTION_DAYS also
  lives there so callers and tests share the constant.
- Replace the bodies in index.js with thin wrappers that pass the module-
  level state into the pure helpers. Call sites and behavior are
  unchanged; index.js shrinks by ~60 lines.
- Move the cleanCompletedJobs logging into the cron caller so the pure
  helper returns a result object (jobs, removed, cutoff) that tests can
  assert on without capturing stdout.
- Add test/helpers.test.js with 43 assertions across 10 suites covering
  the enable/disable gating, per-bot draft isolation, authorization,
  OAuth URL construction, retention filter (including endTime -> startTime
  -> created fallback and the safety default for jobs missing a
  timestamp), and the duration formatter.
- Wire `npm test` to `node --test test/*.test.js` (no new deps, uses the
  built-in node:test runner) and document it in the README.

Smoke test confirms unchanged HTTP behavior for /info (known + unknown
bots), the requireBot 404 gate, and the 401 path on jobs/list/completed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 18:21:02 -04:00

25 lines
624 B
JSON

{
"name": "collabcentral",
"version": "1.0.0",
"description": "Micro-service for sending messages to the organization.",
"main": "index.js",
"scripts": {
"start": "node --env-file=.env index.js",
"test": "node --test test/*.test.js"
},
"author": "Joseph B. McQueen",
"license": "ISC",
"type": "module",
"dependencies": {
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"express": "^4.18.2",
"form-data": "^4.0.0",
"multer": "^1.4.5-lts.1",
"node-cron": "^3.0.2",
"node-fetch": "^3.3.2",
"p-queue": "^7.4.1",
"sharp": "^0.32.6",
"uuid": "^9.0.1"
}
}