Instruction file imported from artem-ibragimov/dicom_viewer_online (
.github/instructions/api.instructions.md). Copyright stays with the author.
API boundary rules
fetchbelongs in*.api.tswrappers or in existing server-side API boundaries such as Next.js route handlers.- Keep request construction, response parsing, and transport-level error handling centralized here.
- Return typed DTOs or typed domain payloads.
- Do not leak transport parsing into containers or presentational components.
- Normalize failures explicitly and return deterministic error shapes.
- Keep user-visible text out of transport code unless intentionally returned as localized content by design.
- Do not prefix promise-returning calls with
voidjust to discard the result. In route handlers, eitherawait, return, or call directly for intentional fire-and-forget work with explicit failure handling in the callee. - Do not use
while (true)orfor (;;)for polling or waiting. Prefer recursion or explicitly bounded iteration with a visible deadline or exit condition. - Prefer guard-style
if+returnwith braces overswitch/casefor request branching and response mapping. - Do not use braceless
ifstatements in route handlers or API wrappers.