forked from wasem-ibrahim/covid_GraphQL_API
-
Notifications
You must be signed in to change notification settings - Fork 0
Covid GraphQL APIs #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
awartani
wants to merge
10
commits into
base_branch
Choose a base branch
from
main
base: base_branch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0a479db
Last commit
wasem-ibrahim 09b33f2
Update README.md
wasem-ibrahim 9ad8ee2
added back authintication
wasem-ibrahim 136d32d
Update README.md
wasem-ibrahim a6478a6
Update README.md
wasem-ibrahim 3b4f637
Update README.md
wasem-ibrahim a35e62a
Update README.md
wasem-ibrahim 511f52b
Update README.md
wasem-ibrahim 18837c8
Update README.md
wasem-ibrahim b6d4019
Update README.md
wasem-ibrahim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,88 @@ | ||
| # covid_GraphQL_API | ||
| # covid_GraphQL_API | ||
|
|
||
| ## This project contains both GraphQL API and a REST API for fetching data from `https://api.covid19api.com` for certain countries. | ||
|
|
||
| ### The features that are included are the following: | ||
| * Registering and Loggin in for Users. | ||
| * Additional layer of authintication using JWT Tokens | ||
| * Adding, Removing, Updating, and deleting countries | ||
| * Adding, Removing, Updating, and deleteing indivisual Covid Statistics. | ||
| * Pagination for GraphQL Responses | ||
| * Monitoring certain countrie for certain users | ||
| * Subscription to certain countries and getting updates on stats for them daily | ||
|
|
||
| ### To run the server, you'll need to do the following: | ||
| 1. Clone the repo | ||
| 2. Run `go mod tidy` to get all of the reuquired packages from "go.mod". | ||
| 3. Change the port inside of `server.go` file if needed, by default it runs on ```8080``` | ||
| 4. Run `go run server.go` in the terminal to launch the server | ||
|
|
||
| ## To use the GraphQL UI to see all of the documentations for each query, head to `http://localhost:8080/` to see the UI. However, to interact with the API, you'll need to use `http://localhost:8080/query` | ||
| *Note: Keep in mind you'll need to provide authorization when using this approach to send requests. | ||
|
|
||
| ## To use the REST API, you can use the following URLs to query the API by navigating to /api/ | ||
| - GET /user: Returns a User by username. | ||
| - GET /countries/{id}: Returns a Country by ID. | ||
| - GET /countries: Returns a list of countries. | ||
| - POST /countries: Creates a new Country. | ||
| - PUT /countries/{id}: Updates an existing Country by ID. | ||
| - DELETE /countries/{id}: Deletes an existing Country by ID. | ||
| - GET /covid-stats/{id}: Returns a CovidStatistic by ID. | ||
| - GET /covid-stats: Returns a list of CovidStatistics. | ||
| - POST /covid-stats: Creates a new CovidStatistic. | ||
| - PUT /covid-stats/{id}: Updates an existing CovidStatistic by ID. | ||
| - DELETE /covid-stats/{id}: Deletes an existing CovidStatistic by ID. | ||
| - GET /users/{userid}/monitored-countries: Returns a list of monitored countries for a User by ID. | ||
| - POST /users/{userid}/monitored-countries: Adds a new monitored country for a User by ID. | ||
| - DELETE /users/{userid}/monitored-countries/{countryId}: Removes a monitored country for a User by ID and Country ID. | ||
| - GET /countries/top-by-case-type/{caseType}/{limit}/{userId}: Returns a list of top countries by case type for a User by ID. | ||
| - GET /countries/{countryId}/death-percentage: Returns the death percentage for a Country by ID. | ||
| - POST /register: Registers a new user. | ||
| - POST /login: Logs in a user. | ||
| - DELETE /users/{userId}: Deletes a user by ID. | ||
| - PUT /users/{userId}: Updates a user by ID. | ||
| - POST /refresh-covid-data: Refreshes COVID data for all countries. | ||
|
|
||
| * Addition/Updating a new country body looks like this: | ||
| ``` | ||
| { | ||
| "name": "Canada", | ||
| "code": "CA" | ||
| } | ||
| ``` | ||
| * Addition/Updating a single covid stat looks like this: | ||
| ``` | ||
| { | ||
| "id": 1, | ||
| "country_id": 1, | ||
| "date": "2022-03-29T00:00:00Z", | ||
| "confirmed_cases": 5000, | ||
| "deaths": 200, | ||
| "recovered": 3000 | ||
| } | ||
| ``` | ||
|
|
||
| * Addition/Updating monitored countries: | ||
| ``` | ||
| { | ||
| "countryId": 1 | ||
| } | ||
| ``` | ||
| * Registering a new user: | ||
|
|
||
| ``` | ||
| { | ||
| "username": "examplename", | ||
| "email": "examplename@example.com", | ||
| "password": "Password1234!" | ||
| } | ||
| ``` | ||
|
|
||
| * Logging in: | ||
| ``` | ||
| { | ||
| "username": "examplename", | ||
| "password": "Password1234!" | ||
| } | ||
| ``` | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you create REST APIs and graphql support?