Skip to content

feat(api): add GET /api/actions/unified endpoint (closes #155)#185

Open
akuraposo wants to merge 1 commit into
David-patrick-chuks:mainfrom
akuraposo:feat/unified-action-log-155
Open

feat(api): add GET /api/actions/unified endpoint (closes #155)#185
akuraposo wants to merge 1 commit into
David-patrick-chuks:mainfrom
akuraposo:feat/unified-action-log-155

Conversation

@akuraposo

Copy link
Copy Markdown

Summary

Implements GET /api/actions/unified — a merged, paginated action log endpoint that combines Instagram and Twitter actions into a single consistent JSON schema. Closes #155.

This delivers the Unified action log (IG/Twitter/GitHub) roadmap item under 3) Data and Storage. GitHub actions are stubbed/omitted per the spec; the focus is on the IG + Twitter merge.

Endpoint

GET /api/actions/unified
Auth: JWT cookie (same as other /api/actions/* routes)

Query params

param default notes
limit 20 max 100
offset 0
account optional account filter
status success or error
sort desc asc or desc (by timestamp)

Response shape

{
  "actions": [
    {
      "platform": "twitter",
      "action": "tweet",
      "timestamp": "2026-07-01T11:00:00.000Z",
      "status": "success",
      "metadata": {
        "id": "tw-1",
        "account": "default",
        "username": "tw_user",
        "error": null,
        "details": { "tweetId": "999" }
      }
    }
  ],
  "pagination": { "total": 2, "limit": 20, "offset": 0, "hasMore": false }
}

Each action has the consistent shape required by the bounty: platform, action, timestamp, status, and metadata.

Implementation notes

  • Fetches IG and Twitter logs in parallel via the existing listActionLogs service (with platform filter), over-fetching (limit * 2 per platform, capped at 100) so that after merging + sorting + paginating the caller still gets a full page in the common case.
  • Merges client-side, sorts by timestamp (newest first by default), then paginates.
  • Reuses the existing ActionLogStatus type and listActionLogs service — no new DB schema, no new file-based store.
  • Registered in the /api/docs endpoint list so it shows up in the API documentation.

Acceptance criteria checklist

  • GET /api/actions/unified responds with HTTP 200
  • Response includes actions from both IG and Twitter sources in one array
  • Each action has a consistent shape: platform, action, timestamp, status, and metadata
  • Supports pagination via ?limit= and ?offset= query params
  • Includes at least one test in apps/api/src/routes/api.test.ts (4 new tests added)
  • PR references this issue (closes #155)

Tests

4 new test cases in apps/api/src/routes/api.test.ts, all passing:

  1. responds with 401 without authentication
  2. returns a merged, paginated IG + Twitter action log — verifies both platforms present, consistent shape, sorted desc by timestamp, pagination metadata
  3. honours limit and offset pagination params
  4. returns 500 when the action log service throws
PASS src/routes/api.test.ts
Tests: 16 passed, 16 total

Closes #155

/claim #155

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant