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>
31 lines
899 B
TypeScript
31 lines
899 B
TypeScript
import type { MetadataRoute } from 'next'
|
|
|
|
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://gitgram.app'
|
|
|
|
// Static, always-public marketing/discovery routes. User/repo profile pages
|
|
// are dynamic ([username], [owner]/[repo]) and intentionally left out here
|
|
// rather than querying the database at build time from this file; add a
|
|
// dedicated sitemap route (e.g. app/sitemap/[id]/route.ts with
|
|
// generateSitemaps) if those need to be indexed individually.
|
|
const STATIC_ROUTES = [
|
|
'',
|
|
'/explore',
|
|
'/discover',
|
|
'/trending',
|
|
'/search',
|
|
'/pricing',
|
|
'/about',
|
|
'/terms',
|
|
'/privacy-policy',
|
|
]
|
|
|
|
export default function sitemap(): MetadataRoute.Sitemap {
|
|
const now = new Date()
|
|
return STATIC_ROUTES.map((path) => ({
|
|
url: `${SITE_URL}${path}`,
|
|
lastModified: now,
|
|
changeFrequency: path === '' ? 'daily' : 'weekly',
|
|
priority: path === '' ? 1 : 0.7,
|
|
}))
|
|
}
|