coyotte508's picture
coyotte508 HF staff
✨ Products listing in admin
de10f77
raw
history blame
No virus
458 Bytes
import { collections } from '$lib/server/db';
import { error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
export const GET: RequestHandler = async ({ params }) => {
const fs = await collections.picturesFs.findOne({ _id: params.id });
if (!fs) {
throw error(404, 'Image non trouvée');
}
return new Response(new Uint8Array(fs.data.buffer, 0, fs.data.buffer.byteLength), {
headers: { 'Content-Type': 'image/webp' }
});
};