`npm run dev` (nodemon --exec ts-node) crashed on startup with 8 TS2769
errors ("RateLimitRequestHandler not assignable to Application") every
time -- the documented quick-start path in README.md never actually
worked.
Root cause: this is an npm workspaces monorepo. express-rate-limit is
only hoisted to the monorepo root node_modules, not nested under
gitgram/backend/node_modules. Its own .d.ts resolves `express` by
walking up node_modules from wherever the package physically lives, so
it lands on the root's hoisted express@4 (and @types/express-serve-
static-core@4.19.8) instead of this package's own pinned express@5.1.0
/ @types/express@5.0.5 -- producing a real-looking but spurious cross-
package type mismatch on every `app.use(limiter)` call.
`npx tsc` / `tsc --noEmit` (the actual build and CI gate) do not hit
this at all and stay green -- confirmed before and after this change.
Set `transpileOnly: true` for the dev-loop ts-node process (the
standard fix for this exact class of ts-node + monorepo hoisting
false positive), so `npm run dev` boots instead of crashing on typings
that aren't a real bug in this project's own code.
Verified for real, not just via tsc:
- Spun up throwaway local postgres+redis containers, ran
`prisma migrate deploy` (4/4 migrations clean), booted the backend
with `npm run dev`'s actual command -- it now boots and serves
/health with a live DB connection; it previously hard-crashed before
a single request.
- Re-ran the full messaging + cross-tenant IDOR flow live end-to-end:
registered 3 real users, created a real group chat (A+B), both
members send/read successfully (201/200), and a non-member (C)
gets a real 403 on both GET /messages/chats/:chatId and
POST /messages with that chatId -- the IDOR fix from 487e4312 still
holds.
- Re-ran tests/messages.test.ts with and without this change (via git
stash): identical 17 failed / 15 passed both times, proving this is
the same pre-existing mocked-Prisma flakiness already documented in
plans/back-catalog.md, not a regression from this fix.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Audited gitgram-ai end to end by actually running the backend against a
live Postgres instance (not just reading/trusting the existing Jest
suite, which mocks Prisma and therefore never hits real FK constraints
or real route wiring).
Critical, feature-breaking bug: Message.senderId/receiverId and
MessageReaction.userId are foreign keys into Account, but every
messaging controller function wrote/read req.userId (a User id) into
those columns directly. Verified live: every message send (1:1 DM and
group chat) failed with a Prisma foreign-key-constraint violation, and
group messages additionally violated the (until now) required
non-null receiverId column since group messages have no single
receiver. Messaging has never worked through this code path. Fixed by
resolving the caller's Account id once per request (matching the
`prisma.account.findFirst({ where: { userId } })` pattern already used
elsewhere in the codebase, e.g. followRequestController) and using it
consistently for every Message/MessageReaction read, write, and
ownership check, while keeping ChatMember/UserBlock/socket rooms on the
real User id they were already consistent with. Added a Prisma
migration making Message.receiverId nullable for group-only messages.
Verified against a live Postgres test database: registered 3 users,
created a group chat, sent and read 1:1 and group messages, reacted,
and marked conversations read -- all succeed now.
Cross-tenant IDOR (same bug class found on Scribase today): GET
/api/v1/messages/chats/:chatId had no membership check at all -- any
authenticated user could read any group chat's messages by chatId
alone (every sibling function in the same file -- getMessage,
reportMessage, assertMessageAccess -- already enforced membership, this
one endpoint was the outlier). Also hardened sendMessage so posting
into a chatId you don't belong to is rejected. Verified live: a
non-member now gets 403 on both reads and writes to a chat they're not
in; an actual member still gets 200.
Unrelated build blocker found while standing up the backend to test
this: gitgram/backend/tsconfig.json set `ignoreDeprecations: "6.0"`,
which the pinned typescript@^5.9.3 doesn't recognize -- `tsc`/`ts-node`
hard-error with TS5103 before compiling a single file. Backend could
not build or boot in dev mode at all. Fixed to "5.0".
SEO gap: gitgram/web (Next.js 14 app dir) had no robots.txt and no
sitemap anywhere, static or dynamic -- zero crawl directives, no
sitemap reference for search engines. Added app/robots.ts (disallows
authenticated-only surfaces, allows public ones) and app/sitemap.ts
(static public marketing/discovery routes).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
TypeScript 6.x makes moduleResolution=node10 (the legacy "node" resolver) a
hard error (TS5107), so `tsc --noEmit` exited 2 and the backend typecheck gate
was red. Add "ignoreDeprecations": "6.0" as TS itself prescribes; node10/
CommonJS resolution semantics are retained intentionally until a deliberate
resolver bump. Typecheck now exits 0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>