mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-17 11:02:06 +00:00
feat(pokedex): add shareable read-only dex links
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { loadSharedPokedex } from '$lib/services/SharedPokedexService';
|
||||
import { renderSharePreview } from '$lib/services/SharePreviewService';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ locals, params }) => {
|
||||
const shared = await loadSharedPokedex(locals.supabase, params.token);
|
||||
if (!shared) throw error(404, 'Shared Pokédex not found');
|
||||
|
||||
const image = await renderSharePreview(shared);
|
||||
return new Response(image, {
|
||||
headers: {
|
||||
'Content-Type': 'image/png',
|
||||
'Cache-Control': 'public, max-age=300, stale-while-revalidate=600',
|
||||
'Content-Length': String(image.byteLength)
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user