Every external call needs a timeout, every timeout needs a fallback — resilience patterns for HTTP, databases, and third-party services
88
90%
Does it follow best practices?
Impact
85%
4.72xAverage score across 5 eval scenarios
Passed
No known issues
Build a Node.js Express API for a social media app's personalized content feed.
GET /api/feed/:userIdQuery parameters: page (default 1), limit (default 20)
The endpoint constructs a personalized feed by pulling data from multiple services:
https://social.internal.example.com/api/users/:userId/following) -- returns the list of accounts the user follows.https://posts.internal.example.com/api/posts/feed) -- POST with the list of followed user IDs to get recent posts, sorted by recency.https://ads.internal.example.com/api/placements) -- returns sponsored content to intersperse in the feed based on user demographics.https://notifications.internal.example.com/api/users/:userId/unread-count) -- returns the count of unread notifications to display in the response header.Return a combined response:
{
"userId": "user-123",
"feed": [
{ "type": "post", "id": "post-1", "author": "user-456", "content": "...", "timestamp": "..." },
{ "type": "ad", "id": "ad-1", "sponsor": "Acme Corp", "content": "...", "cta": "Learn more" },
{ "type": "post", "id": "post-2", "author": "user-789", "content": "...", "timestamp": "..." }
],
"pagination": { "page": 1, "limit": 20, "hasMore": true },
"unreadNotifications": 5
}The social graph and posts services are critical -- without them there is no feed. The ads and notification services are supplementary features.
Produce TypeScript files in a src/ directory:
src/index.ts -- Express server with the feed routesrc/services/socialGraph.ts -- fetches following listsrc/services/posts.ts -- fetches posts for feedsrc/services/ads.ts -- fetches ad placementssrc/services/notifications.ts -- fetches unread countsrc/types.ts -- TypeScript interfacesDo not include test files or build configuration.