Fix #13 add basic admin panel for now

This commit is contained in:
Devin Zuczek
2026-07-17 17:43:18 -04:00
parent b77389012e
commit 9065bf5e54
15 changed files with 901 additions and 238 deletions
+6 -16
View File
@@ -8,22 +8,13 @@ import {
getImagesByRoom,
getPlayerFeed,
getSlideshowImages,
SavedImageType,
setImageCheer,
} from '../images-db'
import { authedId, unauthorized } from '../http'
import type { App } from '../context'
/** Saved-image categories from the C# `SavedImageType` enum (`imgMeta.savedImageType`). */
const SavedImageType = {
None: 0,
ShareCamera: 1,
OutfitThumbnail: 2,
RoomThumbnail: 3,
ProfileThumbnail: 4,
InventionThumbnail: 5,
} as const
/** Bucket folder each SavedImageType is stored under; unknown types fall back to `none`. */
const typeFolder: Record<number, string> = {
[SavedImageType.None]: 'none',
@@ -150,13 +141,12 @@ export const imageRoutes = new Hono<App>({ strict: false })
return c.json(await getPlayerFeed(c.env.DB, playerId, skip, take))
})
// Global slideshow feed — the most recent publicly-listable images (Accessibility
// 0 or 1) across all rooms, newest first, each joined to its creator's username
// and room name. Auth-gated. Returns `{ Images, ValidTill }`, where ValidTill is a
// short (2-minute) cache hint the client refreshes against.
// Global slideshow feed — the most recent publicly-listable ShareCamera photos
// (Accessibility 0 or 1, Type 1) across all rooms, newest first, each joined to its
// creator's username and room name. Public (no auth): it only surfaces already-public
// images and backs the anonymous homepage slideshow. Returns `{ Images, ValidTill }`,
// where ValidTill is a short (2-minute) cache hint the client refreshes against.
.get('/api/images/v1/slideshow', async (c) => {
const id = await authedId(c)
if (id === null) return unauthorized(c)
const Images = await getSlideshowImages(c.env.DB)
const ValidTill = new Date(Date.now() + 2 * 60 * 1000).toISOString()
return c.json({ Images, ValidTill })