{"id":21060116,"url":"https://github.com/mateusrodrigues/hackernews-api","last_synced_at":"2025-10-16T00:43:36.342Z","repository":{"id":36707297,"uuid":"229804985","full_name":"mateusrodrigues/hackernews-api","owner":"mateusrodrigues","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-08T09:27:56.000Z","size":30,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T00:43:04.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mateusrodrigues.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-23T18:39:31.000Z","updated_at":"2019-12-24T18:51:20.000Z","dependencies_parsed_at":"2023-01-17T04:13:41.116Z","dependency_job_id":null,"html_url":"https://github.com/mateusrodrigues/hackernews-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mateusrodrigues/hackernews-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusrodrigues%2Fhackernews-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusrodrigues%2Fhackernews-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusrodrigues%2Fhackernews-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusrodrigues%2Fhackernews-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mateusrodrigues","download_url":"https://codeload.github.com/mateusrodrigues/hackernews-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusrodrigues%2Fhackernews-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265483234,"owners_count":23774170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T17:15:18.887Z","updated_at":"2025-10-16T00:43:31.320Z","avatar_url":"https://github.com/mateusrodrigues.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HackerNews API\n\n## How to Run\n\nThis project uses the following frameworks:\n\n- API\n    - .NET Core 3.1\n    - ASP.NET Core 3.1\n    - Newtonsoft.Json 12.0.3\n    - Swashbuckle.AspNetCore 5.0.0-rc5\n- Unit Tests\n    - .NET Core 3.1\n    - xUnit 2.4.0\n    - Moq 4.13.1\n\nTo run the project, inside of the solutions's root folder, run:\n\n```\ndotnet run --project HackerNews.Api/HackerNews.Api.csproj\n```\n\nAnd point the browser to\n\n```\nhttps://localhost:5001/swagger\n```\n\nThe endpoint can be hit by clicking on the `GET /api/Stories` Swagger menu item, then `Try it out` and `Execute`.\n\nTo run the unit tests, go to the solution's root folder and run:\n\n```\ndotnet test HackerNews.UnitTests/HackerNews.UnitTests.csproj\n```\n\n## Assumptions\n\n- Supposing we're always dealing with stories (not job, comment, or pollopt) as `type`, I'm using `descendents` as the comment count instead of counting the comment IDs in `kids` for performance reasons.\n- The `TimestampToDateTimeOffsetConverter` only implements the `ReadJson` method because it is assumed in this assignment we won't be serializing anything to JSON, rather just deserializing.\n- The memory cache implemented keeps stories cached for **6 hours**. I'm using absolute expiration rather than sliding to allow for possible edits to the story appear in case that happens.\n\n## Future Enhancements\n\n- Replace the ASP.NET Core `IMemoryCache` with a more robust solution, such as Redis, to allow for multiple instances of the API to share the same cache memory.\n- For the `GetStoryDetail_StoryIsInCache_ReadFromCacheAndReturnStory` and `GetStoryDetail_StoryIsNotInCache_SaveToCacheAndReturnStoryFromApi` tests, engineer a better way for object equality instead of asserting the equality of every property.\n- The `CacheService` should be tested with an integration test to allow for better testing with the memory cache external dependency.\n- In `StoriesController`, find a better way to call `GetStoryDetails()` without having to do `.Result`.\n- Remove the Newtonsoft.Json annotations and dependency from the HackerNews.Domain project for better separation of concerns.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateusrodrigues%2Fhackernews-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmateusrodrigues%2Fhackernews-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateusrodrigues%2Fhackernews-api/lists"}