Skip to content

feat: document and comprehensively test download endpoints (#5) - #129

Open
XananasX7 wants to merge 1 commit into
tscircuit:mainfrom
XananasX7:feature/download-endpoints-docs-tests
Open

feat: document and comprehensively test download endpoints (#5)#129
XananasX7 wants to merge 1 commit into
tscircuit:mainfrom
XananasX7:feature/download-endpoints-docs-tests

Conversation

@XananasX7

Copy link
Copy Markdown

Summary

Implements the requirements from #5 — the /files/download endpoint.

The download endpoints already existed in the codebase; this PR:

  • Documents both download forms in the README
  • Updates the API index page to surface the download endpoints
  • Adds a comprehensive dedicated test file with 8 tests covering all edge cases

Download Endpoints Implemented

Query parameter form

GET /files/download?file_path=/path/to/file.txt
GET /files/download?file_id=<uuid>

Path URL form

GET /files/download/path/to/file.txt

Both endpoints return files with:

  • Content-Disposition: attachment; filename="..." for browser download prompts
  • Content-Type: text/plain for text files
  • Content-Type: application/octet-stream + Content-Length for binary files
  • 404 when file is not found

Tests Added

tests/routes/files-download.test.ts with 8 tests:

  • ✅ Text file download via ?file_path=
  • ✅ Text file download via ?file_id=
  • ✅ Binary file download via ?file_path= (byte-level verification)
  • ✅ 404 for missing file (query param)
  • ✅ Text file download via path form (nested path)
  • ✅ Binary file download via path form (byte-level verification)
  • ✅ 404 for missing file (path form)
  • ✅ Single-segment top-level file via path form

Validation

bun test
37 pass, 0 fail

/claim #5

- Document /files/download?file_path= and /files/download/[[file_path]] in README
- Add download routes to the API index page
- Add files-download.test.ts with 8 tests covering:
  - Text file download via query param (file_path and file_id)
  - Binary file download via query param with byte verification
  - 404 handling for missing files (query param)
  - Text file download via path form (nested paths)
  - Binary file download via path form with byte verification
  - 404 handling for missing files (path form)
  - Single-segment top-level file path form

Closes tscircuit#5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant