Giter Site home page Giter Site logo

gaprogman / dwcheckapi Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 17.0 15.56 MB

An ASP.NET Core WebAPI project for all Discworld novels

Home Page: http://dwcheckapi.azurewebsites.net/

License: MIT License

C# 97.28% HTML 0.53% Dockerfile 2.19%
discworld discworld-novels netcore-webapi aspnetcore discworld-search help-wanted

dwcheckapi's Introduction

Hi ๐Ÿ‘‹ My name is Jamie

.NET Software Craftsman

Jamie "GaProgMan" Taylor is a .NET software craftsman, full stack developer and DevOps engineer, and a podcast creator, producer, editor, and host - i.e. podcasting dogsbody. Since 2016, he has been writing, speaking and podcasting about .NET.

  • ๐ŸŒย  I'm based in Leeds, UK
    • ๐Ÿง ย  I'm learning golang

Skills

C++C#JavascriptPythonGoTypescriptHTML5ReactAngularCSS3TailwindCSSBootstrapNodeJSGraphQLMySQL.NET

Socials

Badges

My GitHub Stats

gaprogman's GitHub stats

Top Languages

Support Me

Blogs โŒจ๏ธ

A Journey in .NET Core Waffling Taylors dev


Podcasts ๐ŸŽ™๏ธ

The .NET Core Show Waffling Taylors Tabs & Spaces


Tech that I use ๐Ÿงฐ

C# C# JetBrains Rider Visual Studio Code Nuget Angular Docker HTML5 npm Azure Xamarin.iOS Xamarin.Android


Find Me @ ๐Ÿ“ฃ

LinkedIn YouTube - .NET Core Twitch - .NET Core Stackoverflow Twitter Meetup YouTube - Waffling Taylors Twitch - Waffling Taylors

note: Duplicate YouTube and Twitch here are because I contribute to two channels for each


Unlike other content creators, there isn't one single place where you can find all of the things that he creates (but he's working on something, honest). As such, here are a list of places where you can find his content:

  • A Journey in .NET Core
    • This is a blog which was started back in 2016
    • It chronicles Jamie's journey from .NET Framework into .NET Core
  • The Waffling Taylors
    • This started as a video game blog and has evolved into a weekly podcast
    • It is created and hosted with his brother, all about video games
    • It is not very serious at all
  • The .NET Core Show
    • This is a podcast all about .NET Core and the community around it

Active Projects

The .NET Core Show is a fortnightly podcast about .NET Core and the community around it.

.NET Core Podcast Transcriptions is a collection of all of the transcriptions for The .NET Core Show. I am fixing these machine transcriptions in the open, this is partially to show how much effort is required in order to fix machine transcriptions for podcast - showing how much time and effort is required to create an accessibly podcast.

OwaspHeaders.Core is a NuGet package for ASP .NET Core powered websites which aims to simplify the inclusion of OWASP recommended security headers, which leads to more secure web applications. This open source library is used in a large number of both open source and propriatary applications - I have consulted on several closed source uses of this package.

Links

dwcheckapi's People

Contributors

dependabot[bot] avatar gaprogman avatar hatalaef avatar jamie-taylor-rjj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dwcheckapi's Issues

Books (with details) for a given Series Id

Create an action in the Books controller which takes in a series Id and returns all of the books for that series, ordered by ordinal.

Method signature:

public JsonResult GetForSeries(int seriesId)

Could either return the standard book view model, or a stripped down version (as the UI will only need the cover image and description - users will be able to click a link to navigate to the book profile page)

Needs Unit Tests

Using the xUnit.NET Test template (dotnet new xunit) add unit tests for the source code in the src directory.

Add the xUnit.NET test library to a directory at the root level (i.e. alongside the src directory) called tests

Book view models use Image Url

As of issue #2, book images are no longer external.

Book images are stored in the database, serve the byte array (which represents the image data) to the client.

Include a boolean which informs the client whether the bookImage field contains the base64 string (default) or the image URL (in this case set it to false)

Multiple character entities returned for a single character

Reproduction steps

  • Put a request in for the following API endpoint:

    /Characters/Search?searchString=Vimes

  • Multiple records for Samuel Vimes are returned (one for each book that the character appears in):

   "success":true,
   "result":[
      {
         "characterName":"Samuel Vimes",
         "books":[
            "Monstrous Regiment"
         ],
         "message":null
      },
      {
         "characterName":"Samuel Vimes",
         "books":[
            "The Truth"
         ],
         "message":null
      },
      {
         "characterName":"Samuel Vimes",
         "books":[
            "Night Watch"
         ],
         "message":null
      },
      {
         "characterName":"Samuel Vimes",
         "books":[
            "Snuff"
         ],
         "message":null
      }
   ]
}```
(Example reduced from 13 results, in order to save space)

## Expected Result

- Put a request in for the following API endpoint:

    /Characters/Search?searchString=Vimes

- Single record per character is returned with an array of book entries:

```{
   "success":true,
   "result":[
      {
         "characterName":"Samuel Vimes",
         "books":[
            "Monstrous Regiment",
            "The Truth",
            "Night Watch",
            "Snuff",
            "I Shall Wear Midnight",
            "Thud!",
            "Making Money",
            "Men at Arms",
            "Guards! Guards!",
            "Jingo",
            "The Fifth Elephant",
            "Feet of Clay"
         ],
         "message":null
      },
      {
         "characterName":"Young Sam Vimes",
         "books":[
            "Snuff"
         ],
         "message":null
      }
   ]
}```

Books array should also be populated by book ordinal - this can be logged as a separate issue.

Responses from the API should be compressed

All JSON responses are received from the server in plain text, without any compression. Apply gzip compression to all responses sent from the server using the AddResponseCompression class.

Book data returns base64 string for image, making the request too big

Description of issue

When requesting book details from the database, the returned data for each book contains a base 64 string which represents the cover data.

For individual books, this request data isn't that big. Most of the individual book profile pages top out at about 60-100k (this includes the base 4 string for the cover). But when requesting a page full of book records (i.e. on the search page, when a search string is not supplied) this can end up in the megabytes.

Books data comparison

In the above image, the first request was for a book profile page and the second line was for the book search page with no search string provided. As can be seen, the book search page was orders of magnitude larger than the individual book profile page.

Potential fixes

  • Change the API calls for Books to return all data EXCEPT for the cover image
  • Add an API method in the Books controller which takes a book id and returns the base 64 string which represents the cover data

Series Id is not returned when searching

The following is copied from a comment on Issue 3 on dwCheckUI (GaProgMan/dwCheckUI#3)

Currently when searching (i.e. /Series/Search?searchString=), the following fields are returned:

-seriesName: a string - representing the series name
-bookNames: a string array - representing the names of the books in the series

Proposal is that the API is changed to also return the following field:

-seriesId: a number

Books images are external

Book cover images are currently external to the application (using the BookCoverImageUrl property), however they can be stored in the database locally (using the BookCoverImage property).

  1. Create a Database Api end point which calls a service method to populate the BookCoverImage properties for all books by downloading the file pointed at by the BookCoverImageUrl property.

  2. When parsing new books data, call the method which populates the BookCoverImage property

Results for all searches should be paged

Related to Book search results are not paged #17Book search results are not paged #17 on dwCheckUi

Repro steps

  • Head to /books and search with a blank string
  • All book records from the database are eventually returned
  • Because images are included in the search results, the response from the API server can take up to 19 seconds (on a relatively OK connection)

Suggestions for improvement

  • Search takes in a null able page number, this will do skip and take to get a specific page of data
  • Return paged data (e.g. first 10 records only)
  • As user scrolls to the bottom of the page, send a get request for more records (e.g. infinite scroll)
  • Load the text data separate from the images (fire a second get request for the images, using a loading spinner as each record's image until the response comes back)

As a developer, I would like the dockerfile to be re-written

The dockerfile within this repo is badly written as it was originally based on the first ASP.NET Core docker files. It will not work with the current project layout (at least, not very efficiently) as the project has changed drastically since the dockerfile was created.

Rewrite the dockerfile, and make it more efficient.

Possible Solution

Using the dockerfile from PokeBlazor as a starting point, create a dockerfile for this project.

Remember that each stanza in a dockerfile creates a new layer in the resultant image. Use the following process:

  • Copy sln
  • Copy csproj files
  • dotnet restore
  • Copy code
  • dotnet build --no-restore
  • dotnet run

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.