SCODEMeetup / cbus-biking-LOC

Building a realt time indicator of bike inicdents and level of comfort
0 stars 2 forks source link

Pnorman api #1

Closed PhilNorman2 closed 4 years ago

PhilNorman2 commented 4 years ago

Initial version of cbus biking API. From README.md

Cbus Biking Locations API

API that exposes reports from cyclists including location and description of the incident

Built an deployed using the Ruby on Rails framework.

Prerequisites

  1. Ruby 2.5.8/Rails
  2. Bundler
  3. MySQL 8.0.x

Note: The api connects to the local development MySQL server using the root user id and no password.

API application Initialization

After cloning the repo, navigate to /cbus-biking-LOC/api and enter:

bundle install

Database Initialization

  1. Navigate to /cbus-biking-LOC/api

  2. To create the development database on your MySQL server enter:

    rake db:create

    This creates the database from /cbus-biking-LOC/api/config/database.yml

  3. To create the reports table in your development database enter:

    rake db:schema:load

    This loads the schema from /cbus-biking-LOC/api/db/schema.rb

  4. To seed the reports table with some sample data enter:

    rake db:seed

    This loads seed data from /cbus-biking-LOC/api/db/seeds.rb

Start the API application server

rails s

This will start the application server on your localhost at port 3000

Using the API

  1. POST a report

    http://localhost:3000/api/reports/

    Example JSON body

    {
      "lat": "41.333",
      "long": "-80.231",
      "reason": "crash"
    }
    
  2. GET a report by ID

    http://localhost:3000/api/reports/1

    Example Response:

   {
     "id": 1,
     "lat": 39.9846,
     "long": -82.9192,
     "reason": "crash",
     "created_at": "2020-08-05T16:12:38.892Z",
     "updated_at": "2020-08-05T16:12:38.892Z"
   }
  1. GET all reports

    http://localhost:3000/api/reports

PhilNorman2 commented 4 years ago

I can't give a very detailed review since I don't have any familiarity with ruby/rails, but this definitely looks like a solid start.

OK, I will go ahead and merge this one. Happy to walk you through this or answer questions asynchronously. Once you have the prerequisites it is very simple.