Skip to content

sainamercy/heroes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperHeroes API

This is a simple web API for SuperHeroes and their respective powers

API live link

Pre-Requisites

In order to use this repository you will need the following:

  • Operating System (Windows 10+, Linux 3.8+, or MacOS X 10.7+)
  • RAM >= 4GB
  • Free Space >= 2GB

Built With

This application has been built with the following tools:

  • Ruby v3.0.+
  • SQlite3 v1.6
  • ActiveRecord v7.0.4
  • Rails v7.0.6

Setup Locally

You can setup this repository by following this manual

  1. Clone the repository
    git clone https://github.com/sainamercy/heroes
    
  2. Ensure the ruby gems are setup in your machine
    bundle install
    
  3. Perform any pending database migrations
    rails db:migrate rails db:seed
    
  4. Run to start the server
    rails s
    
    • Use provided link and the endpoints on the ROUTES section to test the API.

Application

This application is a simple web API that allows users to:

  • View all heroes
  • View a specific heroe datails
  • View all power
  • View specific power datails
  • Update specific power
  • Create assiciation between heroes and powers through heroe_power

MODELS

Database schema definitions and associations.

heroes-ERD

ROUTES

  1. GET /heroes - Lists all heroes.

    ## RESPONSE SAMPLE
    [  
    
     { "id": 1, "name": "Kamala Khan", "super_name": "Ms. Marvel" },  
    
     { "id": 2, "name": "Doreen Green", "super_name": "Squirrel Girl" },  
    
     { "id": 3, "name": "Gwen Stacy", "super_name": "Spider-Gwen" }
    
     ]
    
    
  2. GET /heroes/:id - Gets details of a specific heroe

    ## RESPONSE SAMPLE
     {
     "id": 1,
     "name": "Kamala Khan",
     "super_name": "Ms. Marvel",
     "powers": [
         {
         "id": 1,
         "name": "super strength",
         "description": "gives the wielder super-human strengths"
         },
         {
         "id": 2,
         "name": "flight",
         "description": "gives the wielder the ability to fly through the skies at supersonic speed"
         }
     ]
     }
    
    
  3. GET /powers - List all powers.

    ## RESPONSE SAMPLE
    [
     {
         "id": 1,
         "name": "super strength",
         "description": "gives the wielder super-human strengths"
     },
     {
         "id": 1,
         "name": "flight",
         "description": "gives the wielder the ability to fly through the skies at supersonic speed"
     }
     ]
    
  4. GET /powers/:id - Gets details of a specific power

   ## RESPONSE SAMPLE
    {
        "id": 1,
        "name": "super strength",
        "description": "gives the wielder super-human strengths"
     }
  1. PATCH /powers/:id - Update an existing power
   ## RESPONSE SAMPLE
   {
        "message": 'Updated successfully'
    }
  1. POST /hero_powers - create a new hero_power that is associated with an existing Power and heroe.
   ## REQUEST BODY SAMPLE
   {
        "strength": "Average",
        "power_id": 1,
        "hero_id": 3
    }

LICENSE

MIT License

Author

This repository is maintained by:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors