Implement the following plan:
HomeFeed API Implementation Plan
Overview
Create a GET /v1/feed endpoint that serves the HomeFeed with different behavior based on authentication:
- Logged out: Returns global public traces
- Logged in: Returns all traces in user's namespace
API Design
Endpoint: GET /v1/feed
Query Parameters:
limit (optional, default: 50) - Maximum traces to return
Authentication: Optional (behavior differs based on auth state)
Response:
typescript
Files to Create/Modify
1. Create /api/convex/internal/feed.ts
Internal queries for feed data:
_listNamespaceTraces(namespaceId, limit) - All traces in a namespace
_listPublicTraces(limit) - Global public traces with namespace/author info
2. Create /api/convex/services/feed.ts
Service layer with getFeed(ctx, auth, limit):
- If auth: query
_listNamespaceTraces with user's namespaceId
- If no auth: query
_listPublicTraces
3. Create /api/convex/http/v1/feed.ts
HTTP route handler:
typescript
4. Modify /api/convex/http.ts
Add import and registration for feed routes.
5. Create /api/tests/v1/feed.test.ts
Test cases:
- Unauthenticated returns only public traces
- Unauthenticated includes namespace/author info
- Authenticated returns all namespace traces (public + private)
- Authenticated excludes other namespaces' private traces
- Respects limit parameter
- Traces ordered by createdAt descending
- Response includes isAuthenticated flag
Implementation Order
- Create internal queries (
/api/convex/internal/feed.ts)
- Create service layer (
/api/convex/services/feed.ts)
- Create HTTP route (
/api/convex/http/v1/feed.ts)
- Register route in router (
/api/convex/http.ts)
- Write tests (
/api/tests/v1/feed.test.ts)
- Run tests to verify
Verification
bash
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/tarunsachdeva/.claude/projects/-Users-tarunsachdeva-code-traces/4581a321-a46c-4e5b-8c1b-f7f0e1154ce6.jsonl