Add user avatar management and moderation

This commit is contained in:
JB
2026-07-25 00:17:18 -04:00
parent c0834804d4
commit 3f78f0f9d8
30 changed files with 915 additions and 18 deletions
+17
View File
@@ -0,0 +1,17 @@
import { getDatabase } from '$lib/server/database';
import { readUploadedAvatar } from '$lib/server/avatars';
import { error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = async ({ params }) => {
if (!/^[0-9a-f-]{36}$/i.test(params.id)) error(404, 'Avatar not found');
const image = await readUploadedAvatar(await getDatabase(), params.id);
if (!image) error(404, 'Avatar not found');
return new Response(new Uint8Array(image), {
headers: {
'content-type': 'image/webp',
'cache-control': 'public, max-age=31536000, immutable',
'x-content-type-options': 'nosniff'
}
});
};