Skip to content

Conversation

@typelets
Copy link
Owner

Summary

This PR adds comprehensive OpenAPI/Swagger documentation for all API endpoints and refactors route files into a
modular folder structure. It also fixes several TypeScript type inference issues and resolves critical bugs with
route registration and rate limiting.

Changes

📚 OpenAPI/Swagger Documentation

  • Added complete Swagger documentation for all endpoints:
    • Files endpoints (upload, list, get, delete)
    • Code execution endpoints (execute, status, languages, health)
    • Notes endpoints (CRUD, actions, trash, counts)
    • Folders endpoints (CRUD, actions)
    • Users endpoints (profile, delete)
  • Added Swagger UI accessible at /docs
  • Added OpenAPI spec endpoint at /api/openapi.json
  • Created comprehensive schemas in src/lib/openapi-schemas.ts
  • Updated README with link to production Swagger docs: https://api.typelets.com/docs

🗂️ Route Refactoring

  • Refactored monolithic route files into modular folder structure:
    • src/routes/folders/crud.ts + actions.ts
    • src/routes/notes/crud.ts + actions.ts + trash.ts + counts.ts
    • src/routes/files/crud.ts
    • src/routes/users/crud.ts
    • src/routes/code/crud.ts
  • Added descriptive route comments matching consistent style
  • Improved code organization and maintainability

🔧 TypeScript Fixes

  • Fixed type inference issues with @hono/zod-openapi validators
  • Removed explicit Context type annotations that broke type inference
  • Added proper RouteHandler<typeof route> types for separately defined handlers
  • Fixed all type errors across 20+ route handlers
  • Added type guards for error handling (instanceof Error)
  • Added non-null assertions for validated environment variables

🐛 Bug Fixes

  • Critical: Fixed empty trash route being caught by /{id} route
    • Reordered route registration so specific paths are checked before parameterized routes
    • src/server.ts:361 - trash router now registered before crud router
  • Rate Limiting: Increased file download rate limit in development
    • Changed from 100 to 1000 requests per 15 minutes in dev mode
    • Production limit remains at 100 requests per 15 minutes
    • Configurable via HTTP_FILE_RATE_LIMIT_MAX environment variable

📝 Documentation

  • Updated README.md with prominent link to Swagger documentation
  • Added OpenAPI badges and references throughout documentation

Test Plan

  • All routes tested with Swagger UI
  • Empty trash endpoint works correctly
  • File downloads no longer hit rate limits during testing
  • TypeScript compilation succeeds with no errors
  • Linting passes (9 acceptable warnings for OpenAPI dynamic typing)
  • Build succeeds
  • Web application tested successfully
  • Mobile application testing in progress

Breaking Changes

None - this is purely additive and fixes existing bugs.

- Add Swagger/OpenAPI documentation for all API endpoints (files, code, notes, folders, users)
- Refactor route files into modular folder structure (crud/actions/trash/counts)
- Fix TypeScript type inference issues with OpenAPIHono validators
- Fix route registration order to prevent /{id} catching /empty-trash
- Increase file download rate limit to 1000 req/15min in development
- Add Swagger docs link to README (https://api.typelets.com/docs)
@typelets typelets self-assigned this Oct 16, 2025
@typelets typelets merged commit 02326ac into main Oct 16, 2025
4 checks passed
@typelets
Copy link
Owner Author

🎉 This PR is included in version 1.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants