media: webtoon metadata (English title, artist, synopsis, years, adaptation) and stored covers with a cover grid
Deploy production / deploy (push) Successful in 1m24s
Deploy production / deploy (push) Successful in 1m24s
This commit is contained in:
1 parent
96d7333fe9
commit
3a2d3cc78c
10 files changed
+46302
-22
No files matched your search
@@ -0,0 +1,23 @@
|
||||
// Public cover images for media.items (webtoons, podcasts, videos), stored in media.covers so
|
||||
// the page never hotlinks a third-party CDN. Immutable per ?v= (the cover's updated_at).
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { client as sql } from '#lib/server/db/index.js';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ params, url }) => {
|
||||
const [row] =
|
||||
await sql`select mime, bytes from media.covers where item_id = ${Number(params.id)}`;
|
||||
if (!row) error(404, 'Not Found');
|
||||
const body = new Uint8Array(row.bytes as Buffer);
|
||||
return new Response(body, {
|
||||
headers: {
|
||||
'content-type': row.mime as string,
|
||||
'content-length': String(body.byteLength),
|
||||
'cache-control': url.searchParams.has('v')
|
||||
? 'public, max-age=31536000, immutable'
|
||||
: 'public, max-age=86400, stale-while-revalidate=604800',
|
||||
'x-content-type-options': 'nosniff',
|
||||
'content-security-policy': "default-src 'none'; sandbox"
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user