Sweater Weather written in JavaScript/Express instead of Ruby on Rails. This is a weather app using JavaScript, built on NodeJS with the Express framework. Sequelize is used for an ORM. This project is a Mod 4 assignment from the Turing School of Software and Design. Assignment details are available in the @turingschool curriculum repository.
By Deonte Cooper
Deployed on Heroku at: https://express-sweater-weather0312.herokuapp.com/
This solo project is a remake of a Ruby on Rails project called Sweater Weather: https://github.com/djc00p/sweater-weather
GET /api/v1/forecast?location=denver,co
POST /api/v1/[email protected]&password=PASSWORD&password_confirmation=PASSWORD
POST /api/v1/sessions?user[email][email protected]&user[password]=PASSWORD
POST /api/v1/favorites?api_key=USER_API_KEY&location=Denver,%20CO
GET /api/v1/favorites?api_key=USER_API_KEY
DELETE /api/v1/favorites?api_key=USER_API_KEY&location=Denver,%20CO
A weather app using JavaScript, built on NodeJS with the Express framework. Sequelize is used for an ORM.
This project is a Mod 4 assignment from the Turing School of Software and Design. Assignment details are available in the @turingschool curriculum repository.
From the project root, run:
npm install
npx sequelize db:create
npx sequelize db:migrate
npx sequelize db:seed
To start the API server, run npm start
, then access endpoints as described below. Default port on localhost
is 3000
.
Express Sweater Weather |
---|
Account Creation |
Login |
Forecast |
Favoriting Location |
Favorites List |
Favorite Removed |
Provide a valid email, password, and password confirmation. The user will then be provided an api_key for use of the app.
POST /api/v1/users
{
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
HTTP/1.1 201 Created
{
"api_key": "jgn983hy48thw9begh98h4539h4"
}
HTTP/1.1 500 Internal Server Error
{"error": "Internal Server Error"}
Given the email
and password
of an existing user should return that users api_key.
POST /api/v1/sessions
{
"email": "[email protected]",
"password": "password"
}
HTTP/1.1 200 OK
{
"api_key": "jgn983hy48thw9begh98h4539h4"
}
There are no other anticipated failure states. A failure for any other reason is unexpected and will follow the below format.
HTTP/1.1 500 Internal Server Error
{"error": "Internal Server Error"}
API key must be sent If no API key or an incorrect key is provided returns 401 (Unauthorized)
GET /api/v1/forecast?location=denver,co
{
"api_key": "jgn983hy48thw9begh98h4539h4"
}
HTTP/1.1 200 OK
The Body should include 7 or more hourly and daily objects.
{
"location": "Denver, C0",
"currently": {
"summary": "Overcast",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"temperature": 54.91,
"humidity": 0.65,
"pressure": 1020.51,
"windSpeed": 11.91,
"windGust": 23.39,
"windBearing": 294,
"cloudCover": 1,
"visibility": 9.12,
},
"hourly": {
"summary": "Partly cloudy throughout the day and breezy this evening.",
"icon": "wind",
"data": [
{
"time": 1555016400,
"summary": "Overcast",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"temperature": 54.9,
"humidity": 0.65,
"pressure": 1020.8,
"windSpeed": 11.3,
"windGust": 22.64,
"windBearing": 293,
"cloudCover": 1,
"visibility": 9.02,
},
]
},
"daily": {
"summary": "No precipitation throughout the week, with high temperatures bottoming out at 58°F on Monday.",
"icon": "clear-day",
"data": [
{
"time": 1554966000,
"summary": "Partly cloudy throughout the day and breezy in the evening.",
"icon": "wind",
"sunriseTime": 1554990063,
"sunsetTime": 1555036947,
"precipIntensity": 0.0001,
"precipIntensityMax": 0.0011,
"precipIntensityMaxTime": 1555045200,
"precipProbability": 0.11,
"precipType": "rain",
"temperatureHigh": 57.07,
"temperatureLow": 51.47,
"humidity": 0.66,
"pressure": 1020.5,
"windSpeed": 10.94,
"windGust": 33.93,
"cloudCover": 0.38,
"visibility": 9.51,
"temperatureMin": 53.49,
"temperatureMax": 58.44,
},
]
}
}
HTTP/1.1 401 Unauthorized
{"message": "Unauthorized User"}
There are no other anticipated failure states. A failure for any other reason is unexpected and will follow the below format.
HTTP/1.1 500 Internal Server Error
{"error": "Internal Server Error"}
API key must be sent If no API key or an incorrect key is provided returns 401 (Unauthorized)
POST /api/v1/favorites
{
"location": "Denver, CO",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
HTTP/1.1 200 OK
{
"message": "Denver, CO has been added to your favorites"
}
HTTP/1.1 401 Unauthorized
{"message": "Unauthorized User"}
There are no other anticipated failure states. A failure for any other reason is unexpected and will follow the below format.
HTTP/1.1 500 Internal Server Error
{"error": "Internal Server Error"}
API key must be sent If no API key or an incorrect key is provided returns 401 (Unauthorized) Returns each favorite city plus Current weather of that city.
GET /api/v1/favorites
{
"api_key": "jgn983hy48thw9begh98h4539h4"
}
HTTP/1.1 200 OK
[
{
"location": "Denver, CO",
"current_weather": {
"summary": "Overcast",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"temperature": 54.91,
"humidity": 0.65,
"pressure": 1020.51,
"windSpeed": 11.91,
"windGust": 23.39,
"windBearing": 294,
"cloudCover": 1,
"visibility": 9.12,
},
"location": "Golden, CO",
"current_weather": {
"summary": "Sunny",
"icon": "sunny",
"precipIntensity": 0,
"precipProbability": 0,
"temperature": 71.00,
"humidity": 0.50,
"pressure": 1015.10,
"windSpeed": 10.16,
"windGust": 13.40,
"windBearing": 200,
"cloudCover": 0,
"visibility": 8.11,
}
}
]
HTTP/1.1 401 Unauthorized
{"message": "Unauthorized User"}
There are no other anticipated failure states. A failure for any other reason is unexpected and will follow the below format.
HTTP/1.1 500 Internal Server Error
{"error": "Internal Server Error"}
API key must be sent If no API key or an incorrect key is provided returns 401 (Unauthorized)
DELETE /api/v1/favorites
{
"location": "Denver, CO",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
HTTP/1.1 204 No Content
HTTP/1.1 401 Unauthorized
{"message": "Unauthorized User"}
There are no other anticipated failure states. A failure for any other reason is unexpected and will follow the below format.
HTTP/1.1 500 Internal Server Error
{"error": "Internal Server Error"}