fix: use two-step query to fix scoped package 404s on tool detail page

The relation filter `package: { npmPackageName }` was not working correctly.
Now first find the package, then find the tool by packageId.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ajax Davis 2025-12-29 21:50:48 +10:00
parent 5f7a9881ea
commit 2fb63ad506

View file

@ -33,9 +33,19 @@ async function getTool(slug: string[]): Promise<Tool | null> {
return null;
}
// First find the package by npm name
const pkg = await prisma.package.findUnique({
where: { npmPackageName: packageName },
});
if (!pkg) {
return null;
}
// Then find the tool using packageId
const tool = await prisma.tool.findFirst({
where: {
package: { npmPackageName: packageName },
packageId: pkg.id,
...(exportName && { name: exportName }),
},
include: {