Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/prompts.json/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ export async function GET(request: NextRequest) {
identifier: getUserIdentifier(prompt.author),
verified: prompt.author.verified,
},
contributors: prompt.contributors.map((c: any) => ({
contributors: prompt.contributors.map((c: { username: string; name: string | null; avatar: string | null; githubUsername: string | null; verified: boolean }) => ({
username: c.username,
name: c.name,
avatar: c.avatar,
identifier: getUserIdentifier(c),
verified: c.verified,
})),
tags: prompt.tags.map((pt: any) => ({
tags: prompt.tags.map((pt: { tag: { id: string; name: string; slug: string; color: string | null } }) => ({
Comment on lines +193 to +200
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify inline object callback parameter types still exist in this route
rg -nP 'map\s*\(\s*\(\w+\s*:\s*\{[^)]*\}\)\s*=>\s*\(' src/app/prompts.json/route.ts

# Verify Tag.color nullability in Prisma schema
rg -n -A4 -B2 'model Tag|color\s+String' prisma/schema.prisma

Repository: f/prompts.chat

Length of output: 598


Extract inline object types into named interfaces and fix color type to match schema.

Lines 193 and 200 use inline object types as callback parameters, which violates the guideline "Use interface for object shapes". Additionally, line 200 incorrectly types color as string | null when the Prisma schema defines Tag.color as non-nullable String with a default value.

Extract the callback parameter types into named interfaces (ContributorListItem, TagListItem, and PromptTagListItem) and change color: string | null to color: string.

Suggested refactor
+interface ContributorListItem {
+  username: string;
+  name: string | null;
+  avatar: string | null;
+  githubUsername: string | null;
+  verified: boolean;
+}
+
+interface TagListItem {
+  id: string;
+  name: string;
+  slug: string;
+  color: string;
+}
+
+interface PromptTagListItem {
+  tag: TagListItem;
+}
...
-        contributors: prompt.contributors.map((c: { username: string; name: string | null; avatar: string | null; githubUsername: string | null; verified: boolean }) => ({
+        contributors: prompt.contributors.map((c: ContributorListItem) => ({
           username: c.username,
           name: c.name,
           avatar: c.avatar,
           identifier: getUserIdentifier(c),
           verified: c.verified,
         })),
-        tags: prompt.tags.map((pt: { tag: { id: string; name: string; slug: string; color: string | null } }) => ({
+        tags: prompt.tags.map((pt: PromptTagListItem) => ({
           id: pt.tag.id,
           name: pt.tag.name,
           slug: pt.tag.slug,
           color: pt.tag.color,
         })),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/prompts.json/route.ts` around lines 193 - 200, Extract the inline
callback parameter types used in the contributors and tags mappings into named
interfaces: create ContributorListItem for the contributor shape (username,
name, avatar, githubUsername, verified), TagListItem for the inner tag shape
(id, name, slug, color) and PromptTagListItem for the wrapper used in
prompt.tags; then update the mappings in the contributors and tags callbacks to
use these interfaces instead of inline types and change color's type on
TagListItem from string | null to string to match the Prisma schema; reference
getUserIdentifier in the contributors mapping to ensure the identifier call
remains unchanged.

id: pt.tag.id,
name: pt.tag.name,
slug: pt.tag.slug,
Expand Down
Loading