SCRAPE-18: Implement GET /admin/scraper/history endpoint #23

Merged
stephen merged 1 commits from scraper/api-history into dev 2026-02-06 22:34:47 -07:00
Owner

Summary

  • Add GET /api/admin/scraper/history endpoint protected by requireAuth + requireAdmin middleware
  • Implement pagination with limit (1-100, default 30) and offset (default 0) query parameters, with limit capped at 100
  • Add input validation returning 400 for invalid limit/offset values (non-numeric, negative, out of range)
  • Results sorted by startedAt descending (newest first) from the scraper_runs collection
  • Graceful error handling returning 503 on database failures

Test Coverage

  • 20 new tests covering authentication, authorization, pagination defaults, custom parameters, validation errors, edge cases, and error handling
  • All 55 scraperRoutes tests pass

Test Plan

  • Verify endpoint requires authentication (401 without token)
  • Verify endpoint requires admin role (403 for non-admin)
  • Verify default pagination (limit 30, offset 0)
  • Verify custom limit and offset query params work correctly
  • Verify limit is capped at 100
  • Verify 400 response for invalid limit/offset values
  • Verify results are sorted by startedAt descending
  • Verify 503 response on database failure
## Summary - Add GET /api/admin/scraper/history endpoint protected by requireAuth + requireAdmin middleware - Implement pagination with limit (1-100, default 30) and offset (default 0) query parameters, with limit capped at 100 - Add input validation returning 400 for invalid limit/offset values (non-numeric, negative, out of range) - Results sorted by startedAt descending (newest first) from the scraper_runs collection - Graceful error handling returning 503 on database failures ## Test Coverage - 20 new tests covering authentication, authorization, pagination defaults, custom parameters, validation errors, edge cases, and error handling - All 55 scraperRoutes tests pass ## Test Plan - [x] Verify endpoint requires authentication (401 without token) - [x] Verify endpoint requires admin role (403 for non-admin) - [x] Verify default pagination (limit 30, offset 0) - [x] Verify custom limit and offset query params work correctly - [x] Verify limit is capped at 100 - [x] Verify 400 response for invalid limit/offset values - [x] Verify results are sorted by startedAt descending - [x] Verify 503 response on database failure
stephen added 1 commit 2026-02-06 22:27:55 -07:00
Add GET /api/admin/scraper/history endpoint with pagination
All checks were successful
CI/CD Pipeline - Apartment API / Scan Dependencies (pull_request) Successful in 13s
CI/CD Pipeline - Apartment API / Lint & Test (pull_request) Successful in 41s
CI/CD Pipeline - Apartment API / Send Webhook Notification (pull_request) Successful in 2s
CI/CD Pipeline - Apartment API / Build & Push Image (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Deploy to Production (pull_request) Has been skipped
ea6928f933
Implement the scraper history endpoint that returns past scrape run
records from the scraper_runs collection. Features include:

- GET /api/admin/scraper/history protected by requireAuth + requireAdmin
- Pagination via limit (1-100, default 30) and offset (default 0) params
- Input validation returning 400 for invalid limit/offset values
- Results sorted by startedAt descending (newest first)
- Graceful error handling returning 503 on database failures
- 20 new tests covering auth, pagination, validation, and error cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Owner

❌ Changes Requested

Code is solid and well-tested. However, the commit message contains a Co-Authored-By line referencing Claude, which violates the project's no-AI-mentions policy.

Issues:

(commit message):0
Remove the 'Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com' line from the commit message. Project policy prohibits AI/Claude mentions in commits, PRs, and code comments. Use git commit --amend to fix this before merge.

## ❌ Changes Requested Code is solid and well-tested. However, the commit message contains a Co-Authored-By line referencing Claude, which violates the project's no-AI-mentions policy. ### Issues: **(commit message):0** Remove the 'Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>' line from the commit message. Project policy prohibits AI/Claude mentions in commits, PRs, and code comments. Use `git commit --amend` to fix this before merge.
stephen force-pushed scraper/api-history from ea6928f933 to ef15beb622 2026-02-06 22:33:07 -07:00 Compare
stephen merged commit d0538334a5 into dev 2026-02-06 22:34:47 -07:00
stephen deleted branch scraper/api-history 2026-02-06 22:34:47 -07:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stephen/apartment-dashboard-api#23
No description provided.