This is the final Mod 3 project as part of Turing School of Software and Design's Back-End Engineering program. This is a Rails API built to accompany a hypothetical Front-End application consuming the Back-End's endpoints for gathering weather forecast data (current, 8-hour, and 5-day) for a location, a background image of the city, registering users, creating sessions, and creating road trips. The road trip functionality goes further to grab travel time between two entered locations and the weather forecast for that estimated time of arrival.
As always, Test-Driven Development was a major concept practiced in the making of this project.
- Expose API using Test-Driven Development
- Expose API requiring authentication token
- Consume multiple APIs and expose those results through endpoints
- Format JSON using a serializer gem (I used jsonapi-serializer)
This scratch Rails API consumes the MapQuest Geocoding API, the OpenWeather One Call API and the Bing Search API. Utilizing various endpoints from these APIs and manipulating the data through services, facades and poros, my application's backend routes could be called to return JSON-serialized data based on what the 'front end user' would input. Search endpoints include current, hourly and daily forecasts for a location and location photos utilizing the Bing Search API. Frontend users can also register an email and password to receive a randomly-generated API key (all saved in User table) as well as create a Session by providing this API key. Road trips can also be created by providing the API key, an origin location and a destination location. This provides the frontend with the entered locations, drive time, and the forecast of the destination location at the estimated arrival time.
These setup instructions are for Mac OS.
This project requires the use of Ruby 2.5.3
and Rails 5.2.4.3
.
I also use PostgreSQL
as my database.
To setup locally, follow these instructions:
- Fork & Clone Repo
- Fork this repo to your own GitHub account.
- Create a new directory locally or
cd
into whichever directory you wish to clone down to. - Enter
git clone [email protected]:<<YOUR GITHUB USERNAME>>/sweater_weather.git
- Install Gems
- Run
bundle install
to install all gems in the Gemfile - Run
figaro install
to create the hiddenapplication.yml
file
- Run
- Set Up Local Database and Migrations
- Run
rails db:{drop,create,migrate}
- Run
- Add API Keys as ENV Variables
- Sign up for API keys for all three APIs: Bing (requires Azure signup), OpenWeather, and MapQuest
- Enter these keys in the
application.yml
file created above as follows:
MAPQUEST_KEY: <YOUR KEY> OPENWEATHER_KEY: <YOUR KEY> BING_KEY: <YOUR KEY>
cd
into the folder you cloned this repo into and runrails server
.- Run
bundle exec rspec
, and you should see all passing tests.
In an API tool such as Postman, you can experiment with hitting information using the endpoints in this project. To do so:
cd
into whichever folder houses this cloned project.- Run
rails server
from the command line. - Enter
http://localhost:3000
as the domain, followed by whichever endpoint you are trying to hit. See this page for more information.