feat(api): migrate GET /api/instagram/comments
Closed
AR
7mo ago+326+326+012345678901234567890123456789-0-0-0123456789
Migrates the legacy Express GET /api/instagram/comments endpoint into mono/api as a flat Next.js route. Validator owns auth via validateAuthContext; handler returns { runId, datasetId } for wire parity with the legacy ApifyScraperResult. Webhook URL stays pointed at chat.recoupable.com/api/apify per the migration plan.
Test plan
- 401 on Vercel preview without auth
- 400 on Vercel preview without
postUrls - 200 on Vercel preview with valid
postUrls(returnsrunId+datasetId) - Unit tests (handler + validator) green
Summary by cubic
Migrated the legacy Express GET /api/instagram/comments to a flat Next.js route. Preserves the response shape ({ runId, datasetId}) and keeps the webhook target at chat.recoupable.com/api/apify, while adding validation, auth, and safer errors.
- New Features
- Route: GET /api/instagram/comments with CORS preflight,
dynamic: "force-dynamic",maxDuration = 30(usesnext/server). - Validation: supports
postUrls(repeatable),resultsLimit(default 10000),isNewestComments,webhooks(base64 JSON array); 400 on invalid input. - Auth:
validateAuthContextenforces API key; 401 on failure. - Scraping: starts Instagram Comments actor via
apify-client; returnsrunIdanddatasetId; masks internal errors. - Tests: unit tests for handler and validator using
vitest.
- Route: GET /api/instagram/comments with CORS preflight,