Small exercise for a job interview.
Given the sentence The API should return an array of the first 20 "best stories" as returned by the Hacker News API, sorted by their score in a descending order.
I assumed that I didn't need to filter out the items that have Dead
and Deleted
as true
.
I also assumed that the endpoint https://hacker-news.firebaseio.com/v0/beststories.json only returns items with "type": "story"
.
The main improvement I would do would be to use a proper distributed cache like Redis, instead of the built in IMemoryCache.
Some other small improvements that could be made would be to improve the swagger generated documentation and to use Serilog instead of the default Microsoft logging.
If this service increased in scope and size other improvements could be done, like add authentication, add logging to file, extract businness rules to a new class library project (maybe even make it a NuGet package if that business logic would need to be reused somewhere else), etc.
From the command line navigate to CoreHackerNews\CoreHackerNews
and run the command dotnet build
.
From the command line navigate to CoreHackerNews\CoreHackerNews
(same directory as for the build) and run the command dotnet run
.
From the command line navigate to CoreHackerNews\CoreHackerNewsTests
and run the command dotnet test
.
For checking the auto-generated documentation open the following url on the browser: https://localhost:5001/api/documentation.