Giter Club home page Giter Club logo

hackernews-api's Introduction

HackerNews API

How to Run

This project uses the following frameworks:

  • API
    • .NET Core 3.1
    • ASP.NET Core 3.1
    • Newtonsoft.Json 12.0.3
    • Swashbuckle.AspNetCore 5.0.0-rc5
  • Unit Tests
    • .NET Core 3.1
    • xUnit 2.4.0
    • Moq 4.13.1

To run the project, inside of the solutions's root folder, run:

dotnet run --project HackerNews.Api/HackerNews.Api.csproj

And point the browser to

https://localhost:5001/swagger

The endpoint can be hit by clicking on the GET /api/Stories Swagger menu item, then Try it out and Execute.

To run the unit tests, go to the solution's root folder and run:

dotnet test HackerNews.UnitTests/HackerNews.UnitTests.csproj

Assumptions

  • 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.
  • 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.
  • 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.

Future Enhancements

  • 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.
  • 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.
  • The CacheService should be tested with an integration test to allow for better testing with the memory cache external dependency.
  • In StoriesController, find a better way to call GetStoryDetails() without having to do .Result.
  • Remove the Newtonsoft.Json annotations and dependency from the HackerNews.Domain project for better separation of concerns.

hackernews-api's People

Contributors

mateusrodrigues avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.