- Error Handling: Skips stories that fail to fetch and logs errors for debugging.
- Pagination: Supports
page
andpageSize
query parameters for paginated results. - Metadata in Response: Adds total stories, page, and page size in the API response.
- Enhanced Caching: Caches individual story details to reduce repetitive API calls.
- Optimized Performance: Fetches stories in smaller batches to optimize response time.
- .NET 8 SDK or later
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Restore Dependencies:
dotnet restore
-
Run the Application:
dotnet run
-
Access Swagger for API Testing:
- Navigate to
http://localhost:5000/swagger
in your browser.
- Navigate to
Retrieve the top n
stories from Hacker News, sorted by score.
page
: (optional) The page number to retrieve (default: 1).pageSize
: (optional) Number of stories per page (default: 10).
curl "http://localhost:5000/api/stories/top?page=1&pageSize=5"
{
"totalStories": 100,
"page": 1,
"pageSize": 5,
"stories": [
{
"title": "A uBlock Origin update was rejected from the Chrome Web Store",
"uri": "https://github.com/uBlockOrigin/uBlock-issues/issues/745",
"postedBy": "ismaildonmez",
"time": "2019-10-12T13:43:01+00:00",
"score": 1757,
"commentCount": 588
},
{ ... }
]
}
- Distributed Caching: Implement Redis for better scalability.
- Rate Limiting: Add rate limiting to prevent abuse.
- Testing: Write comprehensive unit and integration tests for services and controllers.
This project is licensed under the MIT License.