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).
backend ruleP1universalStack: node
consistencyservicesfilesystemdata-integrity
Route file deletion/IO through a service so DB and storage stay consistent
Deleting a stored file should go through a service that removes both the storage object and the DB record, not just unlink the disk file in the handler.
PR: hegnar-journalist-boost · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | await fs.unlink(path.join(dir, id)); // DB File row left dangling |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | await FileService.deleteFileById(id); // deletes storage object AND DB record |
Explanation (EN)
Objašnjenje (HR)