Giter Site home page Giter Site logo

totallysafepark's Introduction

     ____.                                 .__         __________               __    
    |    |__ ______________    ______ _____|__| ____   \______   \_____ _______|  | __
    |    |  |  \_  __ \__  \  /  ___//  ___/  |/ ___\   |     ___/\__  \\_  __ \  |/ /
/\__|    |  |  /|  | \// __ \_\___ \ \___ \|  \  \___   |    |     / __ \|  | \/    < 
\________|____/ |__|  (____  /____  >____  >__|\___  >  |____|    (____  /__|  |__|_ \
                           \/     \/     \/        \/                  \/           \/

Jurassic Park Setup

Versions & Requirements

  • Ruby 3.1.2
  • Rails 7.0.7
  • PostgreSQL

Setup and Server Start

  1. Run bundle install to install all gems
  2. Run rails db:create to create the database
  3. Run rails db:migrate to run migrations
  4. Run rails db:seed to seed the database
  5. Run rails s to start the server
  6. Navigate to localhost:3000 in your browser
  7. Enjoy, but warning dinosaurs are dangerous and may eat you. Good luck.

Notes

  • The seed file will create 5 users. Please see 'db/seeds.rb' for login and API credentials.
  • To connect to the API, use the following headers:
    • Accept: application/json
    • X-User-Email
    • X-User-Token

API Request Example

curl --location --request GET 'localhost:3000/cages' \
--header 'X-User-Email: [email protected]' \
--header 'X-User-Token: A4BpSG' \
--header 'Accept: application/json'

User Roles

  • All Users: Can create, update, and delete dinosaurs, along with update cages.
  • Builders: Can create, cages.

Testing

  • Run rails test to run all tests

API Endpoints

Dinosaurs

  • GET /dinosaurs - Returns all dinosaurs
    • Filter by species: GET /dinosaurs?species=0
    • Filter by diet: GET /dinosaurs?diet=0

Species Values

Species Value
Tyrannosaurus 0
Velociraptor 1
Spinosaurus 2
Megalosaurus 3
Brachiosaurus 4
Stegosaurus 5
Ankylosaurus 6
Triceratops 7

Diet Values

Diet Value
Herbivore 0
Carnivore 1
  • GET /dinosaurs/:id - Returns a single dinosaur
  • POST /dinosaurs - Creates a new dinosaur Required Params: name, species, cage_id
    • species: Tyrannosaurus, Velociraptor, Spinosaurus, Megalosaurus, Brachiosaurus, Stegosaurus, Ankylosaurus, Triceratops
  • PUT /dinosaurs/:id - Updates a dinosaur
  • DELETE /dinosaurs/:id - Deletes a dinosaur

Cages

  • GET /cages - Returns all cages
    • Filter by cage type: GET /cages?cage_type=0
    • Filter by max capacity: GET /cages?max_capacity=0
    • Filter by power status: GET /cages?power=false

Cage Type Values

Cage Type Value
Herbivore 0
Carnivore 1

Power Values

Power Status Value
Active true
Down false
  • GET /cages/:id - Returns a single cage
  • POST /cages - Creates a new cage Required Params: name, max_capacity, cage_type
    • cage_types: herbivore, carnivore
  • PUT /cages/:id - Updates a cage
  • DELETE /cages/:id - Deletes a cage

API Examples

Access Error

{
    "error": "Ah, ah, ah! You didn't say the magic word!"
}

Cage Example

// Create a new cage
curl --location 'localhost:3000/cages' \
--header 'X-User-Email: [email protected]' \
--header 'X-User-Token: IALVOP' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "cage": {
        "name": "My cage that is very safe",
        "max_capacity": 8,
        "power": true,
        "cage_type": 1
    }
}'

Dinosaur Example

// Create a new dinosaur
curl --location 'localhost:3000/dinosaurs' \
--header 'X-User-Email: [email protected]' \
--header 'X-User-Token: IALVOP' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "dinosaur": {
        "name": "Dino Mite",
        "species": 0,
        "cage_id": 5
    }
}'

totallysafepark's People

Contributors

gregwinn avatar

Watchers

 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.