fix: send 404 when no miis are found in search API route

also remove redundant line in README
This commit is contained in:
trafficlunar 2025-11-16 21:27:24 +00:00
parent 196f9d4640
commit 67bd6a4297
2 changed files with 8 additions and 17 deletions

10
API.md
View file

@ -3,8 +3,6 @@
Welcome to the TomodachiShare API Reference!
Some routes may require authentication (see [Protected](#protected-endpoints) section - _TODO_).
Schema properties marked with a **\*** are required.
## Public Endpoints
### **Search Miis**
@ -28,7 +26,7 @@ Searches Miis by name, tags, and description.
#### **Examples**
```
https://tomodachishare.com/api/search?q={query}
https://tomodachishare.com/api/search?q=frieren
```
```
@ -43,6 +41,12 @@ Returns an array of Mii IDs:
[1, 204, 295, 1024]
```
When no Miis are found:
```json
{ "error": "No Miis found!" }
```
---
### **Get Mii Image / QR Code / Metadata Image**

View file

@ -29,19 +29,6 @@ export async function GET(request: NextRequest) {
...(gender && { gender: { equals: gender } }),
};
const select: Prisma.MiiSelect = {
id: true,
name: true,
imageCount: true,
tags: true,
createdAt: true,
gender: true,
// Like count
_count: {
select: { likedBy: true },
},
};
const skip = (page - 1) * limit;
if (sort === "random") {
@ -54,7 +41,7 @@ export async function GET(request: NextRequest) {
select: { id: true },
});
if (matchingIds.length === 0) return;
if (matchingIds.length === 0) return rateLimit.sendResponse({ error: "No Miis found!" }, 404);
const rng = seedrandom(randomSeed.toString());