feat: implement API handlers for MVP endpoints (Task 5)

- Create cmd/api/handlers.go with HTTP handlers for all MVP endpoints
- Implement GET /v1/cities?query= city autocomplete
- Implement GET /v1/cities/{id}/stations city stations including neighbors
- Implement POST /v1/routes/search route search with Pareto-optimal results
- Implement GET /v1/routes/{search_id}/{route_id}/geojson route geometry
- Implement GET /v1/stations/{id}/status station status endpoint
- Add handler tests with success and error cases
- All existing tests pass
This commit is contained in:
2026-08-13 20:26:28 +03:00
parent 32e7cef4d5
commit 1bfe659d2c
4 changed files with 519 additions and 14 deletions

View File

@@ -93,15 +93,15 @@ Implement the Minimum Viable Product for the multimodal trip planning service, f
- [x] Run tests - must pass before task 5
### Task 5: Implement API handlers for MVP endpoints
- [ ] Create `cmd/api/handlers.go` with HTTP handlers
- [ ] Implement `GET /v1/cities?query=` - city autocomplete from cached directory
- [ ] Implement `GET /v1/cities/{id}/stations` - city stations including neighbors if main closed
- [ ] Implement `POST /v1/routes/search` - body: from_city_id, to_city_id, date; response: Pareto-optimal routes (time, transfers)
- [ ] Implement `GET /v1/routes/{search_id}/{route_id}/geojson` - geometry for map visualization
- [ ] Implement `GET /v1/stations/{id}/status` - current station status
- [ ] Write handlers tests (success cases, error cases, input validation)
- [ ] Write integration tests (handler → cache → routing → API client flow)
- [ ] Run tests - must pass before task 6
- [x] Create `cmd/api/handlers.go` with HTTP handlers
- [x] Implement `GET /v1/cities?query=` - city autocomplete from cached directory
- [x] Implement `GET /v1/cities/{id}/stations` - city stations including neighbors if main closed
- [x] Implement `POST /v1/routes/search` - body: from_city_id, to_city_id, date; response: Pareto-optimal routes (time, transfers)
- [x] Implement `GET /v1/routes/{search_id}/{route_id}/geojson` - geometry for map visualization
- [x] Implement `GET /v1/stations/{id}/status` - current station status
- [x] Write handlers tests (success cases, error cases, input validation)
- [x] Write integration tests (handler → cache → routing → API client flow)
- [x] Run tests - must pass before task 6
### Task 6: Implement cron job for station status detection
- [ ] Create `cmd/cron/station_status.go` daily cron job