Spaces:
Paused
Paused
Add /api/debug/thumbnail/:name endpoint to verify thumbnail file status
Browse filesThis endpoint checks if a thumbnail file exists, its size, and the URL
to access it via the static file route.
index.ts
CHANGED
|
@@ -945,6 +945,24 @@ const server = Bun.serve({
|
|
| 945 |
});
|
| 946 |
},
|
| 947 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 948 |
"/api/avatars": {
|
| 949 |
GET: async () => {
|
| 950 |
const names = await listAvatars();
|
|
|
|
| 945 |
});
|
| 946 |
},
|
| 947 |
},
|
| 948 |
+
"/api/debug/thumbnail/:name": {
|
| 949 |
+
GET: async (req) => {
|
| 950 |
+
const name = req.params.name;
|
| 951 |
+
const thumbName = `${name}.thumb.png`;
|
| 952 |
+
const thumbPath = join(process.cwd(), "public/avatars", thumbName);
|
| 953 |
+
const file = Bun.file(thumbPath);
|
| 954 |
+
const exists = await file.exists();
|
| 955 |
+
const size = exists ? file.size : 0;
|
| 956 |
+
return Response.json({
|
| 957 |
+
name,
|
| 958 |
+
thumbName,
|
| 959 |
+
thumbPath,
|
| 960 |
+
exists,
|
| 961 |
+
size,
|
| 962 |
+
url: `/avatars/${thumbName}`
|
| 963 |
+
});
|
| 964 |
+
},
|
| 965 |
+
},
|
| 966 |
"/api/avatars": {
|
| 967 |
GET: async () => {
|
| 968 |
const names = await listAvatars();
|