Giter Site home page Giter Site logo

animals-api's Introduction

Animals API ๐Ÿฆ๐Ÿฆ“๐Ÿต

In this project, we sought the concepts of object orientation, code reuse, clean code and understanding the architecture of a .NET project.

This solution contains two projects:

  • Api -> Animals.Api
  • Commons -> Animals.Commons

For this challenge, we created a controller that has the purpose of returning a list of 20 different animals, each one with its characteristics. Let's return the following animals and their particularities:


Animal Dog

Properties:

  • Name
  • Color
  • Age
  • Size (small, medium, big)
  • Breed

Animal Cat

Properties:

  • Name
  • Color
  • Age
  • Size (small, medium, big)
  • HairType

Animal Horse

Properties:

  • Name
  • Color
  • Age
  • Size (small, medium, big)

Animal Bird

Properties:

  • Color
  • Size (small, medium, big)
  • WingSize (small, medium, big)
  • FlightSpeed

  1. As the project is made in net6, it made sense to understand its nuances and adapt the project to the standards adopted in this version. An example would be namespace encapsulation which is no longer required.

  2. The first challenge requested the creation of animals randomly, in your solution you used the class constructor for this construction. As a refactoring point, I believe that implementing a creational-type design pattern would be ideal for creating instances of these animals.

  3. Today the solution only contains a GET method that is responsible for creating and returning the animals, I believe we can improve this dynamic, for that I propose the creation of a POST with the following characteristics:

  • The endpoint receives as input 1 or N types of animals and the quantity to be generated.
  • It must generate the number of animals requested and store it in memory on a map using a UUID as a key.
  • With each new request on the endpoint to generate the list of animals, it increments the map, including a new list of animals.

Example:

{

   "ID1": [animal1, animal2],
   "ID2": [animal1, animal2, animal3]
   ...
}
  • "Get all" returns a list containing each previously stored animal list:
{
 [
   {
      id: "abc",
      animals: [animal1, animal2],
   },
   {
      id: "xyz",
      animals: [animal1, animal2, animal3],
   }
   {...}
 ]
}
  • "Get by Id" returns a list of animals filtered by the ID generated in the POST.

Hot to use it?

  • POST Feel free to use Postman or Insomnia! Make sure to send your JSON to http://localhost:5040/animals.
{
  "types": ["cat", "dog"],
	"quantity": 5	
}
  • GET Output at http://localhost:5040/animals

image

Any feedback is welcome! Thanks! ๐Ÿ˜ป

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.