Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: universal
api-designbatchinghttpfile-upload
Prefer one batched request over a request per item
When uploading or submitting multiple items, send them in a single multipart/batched request rather than firing one request per item, which simplifies error handling and atomicity.
PR: hegnar-journalist-boost · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | await Promise.all(files.map(f => uploadOne(f))); // N requests, partial-failure mess |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const form = new FormData(); |
| 2 | files.forEach(f => form.append('files[]', f)); |
| 3 | await fetch('/api/upload', { method: 'POST', body: form }); // one request |
Explanation (EN)
Objašnjenje (HR)