Skip to content

projectjimcs/sample-weather-api-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Weathering App

A simple web application in which a user can register and login to access getting the weather for their inputted city

Description

Application includes basic registration, login and querying for weather information for an inputted city. JWT was used for the authentication logic. The backend is built with express and graphql while the frontend uses react.

Getting Started

  • MySql required. MySql Download Once installed, Go into mysql on the command line (ex. mysql -uroot -proot). Then run create database qlsample and exit.
  • MySqL 8.0.27-arm64 was the version used on the development Mac. 8.0.18 was used for my older Mac on Mojave to ensure working.
  • Open weather API key required. Can be obtained free at Open Weather API
  • Node version 16.16.0+ required. An older version may work, but tested on 16.16.0 and 17.2.
  • Go into mysql on the command line (ex. mysql -uroot -proot). Then run:
create database qlsample

Dependencies

  • There are a number of dependencies and libraries which can all be found through client/package.json and server/package.json
  • Library usage was kept to a minimum to get things working.
  • Tested on MacOS Monterey 12.1 and Mojave 10.14.6

Installing

Step 1: Clone the repository:

git clone [email protected]:projectjimcs/sample-weather-api-graphql.git

or

git clone https://github.com/projectjimcs/sample-weather-api-graphql.git

Step 2: Go into the project directory:

cd sample-weather-api-graphql

Step 3: Go into the client folder (cd client) and run:

npm install

Step 4: Go into the server folder (cd server) and run:

npm install

Step 5: In the server folder, create a new env file (touch .env) and copy the contents of .env.example over to it

Step 6: Open the env file and set the port to 8000. The JWT_SECRET can be anything, DB_USER and DB_PASSWORD is whatever you inputted for your database and WEATHER_API_KEY is the key you got from the getting started section

Step 7: Go into the server folder and run migrations:

node node_modules/db-migrate/bin/db-migrate up

Executing program

Step 1: Open two terminal window, on one of them, go to the client folder and run:

npm start

On the second terminal window, go to the server folder and run:

npm run dev

Step 2: Go to localhost:3000 to see the application, though it should already automatically pop up after running npm start Step 3: Visit http://localhost:8000/graphql (Optional)

Help

A common issue that you run may into goes along the lines of:

Client does not support authentication protocol requested by server

if this occurs, run the following in mysql:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';`

Where root as your user localhost as your URL and password as your password. Then run:

flush privileges;

Another thing to check is node version which could cause issues, make sure the version is not from way back (node -v)

Authors

Created By: Jim Lin

Images Used (All credits to the owners)

Version History

  • 0.1
    • Initial Release

License

Copyright 2022 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Screenshots

'Screenshot 1' 'Screenshot 2' 'Screenshot 3' 'Screenshot 4'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published