refactor(constants): zentrale SW-Timing-Konstanten + minor cleanups
- src/lib/constants.ts: SW_VERSION_QUERY_TIMEOUT_MS, SW_UPDATE_POLL_INTERVAL_MS - pwa.svelte.ts: nutzt die Konstanten statt 1500/30*60_000 - cache-strategy.ts / diff-manifest.ts: RequestShape/ManifestDiff entkapselt (intern statt export, da nirgends extern importiert) - recipes/[id]/image: deutsche Fehlermeldungen auf Englisch (Konsistenz mit allen anderen Endpoints) Findings aus REVIEW-2026-04-18.md (Quick-Wins 6+7) und dead-code.md
This commit is contained in:
@@ -32,13 +32,13 @@ export const POST: RequestHandler = async ({ params, request }) => {
|
||||
|
||||
const form = await request.formData().catch(() => null);
|
||||
const file = form?.get('file');
|
||||
if (!(file instanceof File)) error(400, { message: 'Feld "file" fehlt' });
|
||||
if (file.size === 0) error(400, { message: 'Leere Datei' });
|
||||
if (file.size > MAX_BYTES) error(413, { message: 'Bild zu groß (max. 10 MB)' });
|
||||
if (!(file instanceof File)) error(400, { message: 'Field "file" missing' });
|
||||
if (file.size === 0) error(400, { message: 'Empty file' });
|
||||
if (file.size > MAX_BYTES) error(413, { message: 'Image too large (max 10 MB)' });
|
||||
|
||||
const mime = file.type.toLowerCase();
|
||||
const ext = EXT_BY_MIME[mime];
|
||||
if (!ext) error(415, { message: `Bildformat ${file.type || 'unbekannt'} nicht unterstützt` });
|
||||
if (!ext) error(415, { message: `Image format ${file.type || 'unknown'} not supported` });
|
||||
|
||||
const buf = Buffer.from(await file.arrayBuffer());
|
||||
const hash = createHash('sha256').update(buf).digest('hex');
|
||||
|
||||
Reference in New Issue
Block a user