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 product recommendation service. The service has two endpoints:
GET /api/recommendations/:userIdThis endpoint builds personalized product recommendations by:
https://profiles.internal.example.com/api/users/:userId) to get the user's preferences, purchase history, and demographic data.https://recommendations.internal.example.com/api/suggest) with the user profile data as a POST body to get recommended product IDs.https://catalog.internal.example.com/api/products/batch) with the recommended product IDs to get full product details (name, price, image, description).Return a response like:
{
"userId": "user-123",
"recommendations": [
{ "id": "prod-1", "name": "Wireless Headphones", "price": 79.99, "reason": "Based on your recent purchases" },
{ "id": "prod-2", "name": "USB-C Hub", "price": 45.00, "reason": "Popular in your category" }
]
}GET /api/recommendations/:userId/quickA faster version that only calls the Recommendation Engine with a cached/default profile if the profile service is slow, returning product IDs without full catalog details.
API authentication uses a service token from the SERVICE_AUTH_TOKEN environment variable, sent as a Bearer token in the Authorization header.
Produce TypeScript files in a src/ directory:
src/index.ts -- Express server with routessrc/services/userProfile.ts -- fetches user profile datasrc/services/recommendations.ts -- calls the recommendation enginesrc/services/productCatalog.ts -- fetches product detailssrc/types.ts -- TypeScript interfacesDo not include test files or build configuration.