Member Contribution Report (Elif Kızılkaya) - bounswe/bounswe2023group7 GitHub Wiki

Important Issues Related to the Practice Application

  • #131: Learning NodeJs framework
  • #132: Search for API
  • #133: Learning Docker, Swagger, Testing
  • #158: Described the functionalities I'm going to implement, their views, endpoints, model and steps to my overall task.
  • #161: Described my database model for API with its indexes and functions.
  • #162: Described my endpoints separately and divide my overall task into steps
  • #163: Related to Unit test
  • #165: Swagger API documentation
  • #173: Constructing the frontend project (aka. client folder) & learning React
  • #185: Frontend for Landing page - Home Page
  • #198: Described my frontend views for my functions
  • #200: Related to Milestone 2 report
  • #217: Created remote database with my teammates
  • #225: Created the README.md for server part

Third-Party URIs

I utilized the IP geolocation API, which is an API provided by Abstract API. This API allows retrieving location information based on a user's IP address. It provides data such as the city, region, country, country flag, postal code, and time information which I make use of.

To make the API call, I used the following URI: https://ipgeolocation.abstractapi.com/v1/?api_key=${process.env.LOCATION_TOKEN}&ip_address=${req.query.ip_address}.

This URI is used to send a request to the IP geolocation API of Abstract API. The "${process.env.LOCATION_TOKEN}" part represents the API key, which is a local environment variable and should be provided by you. The "${req.query.ip_address}" is the request parameter used to obtain the user's IP address.

If you would like to learn more about the API, you can visit this link.

API Functions

I have created three functions, including two GET requests and one POST request. These functions are as follows:

  • history - GET: This function retrieves the location history information of a logged-in user based on their email from the database. The route used for this function is /api/location/history. If the user's email is not available, indicating that they are not logged in, it returns a 400 error code. Otherwise, it successfully returns the user's location history.

Example URI: http://18.185.125.88:8080/api/location/history

  • addLocation - POST: This function adds the user's location information to the database using their IP address and email. To accomplish this, a call is made to the IP Geolocation API using the IP address. From the data received in the API response, the city, region, postal code, country, country flag, and current time information are extracted and stored in the database along with the user's email. If the IP address and email are not provided, it returns a 400 error code. The route used for this function is /api/location/addLocation?ip_address=${userIP}

Example URI: http://18.185.125.88:8080/api/location/addLocation?ip_address=193.140.194.16

  • findLocation - GET: In this function, the location information is returned based on the provided IP address. To achieve this, a call is made to the IP Geolocation API using the IP address. Along with the IP address, the retrieved data from the API call, including the city, region, country, country flag, postal code, and current time information, is sent as a response. The route used for this function is /api/location/findLocation?ip_address=${userIP}

Example URI: http://18.185.125.88:8080/api/location/findLocation?ip_address=193.140.194.16

These functions allow for managing location-related data, retrieving location history, adding new location entries to the database, and finding location information based on an IP address.

Unit Tests

I created 5 tests: 2 for /findLocation, 2 for /addLocation, and 1 for /history. Before conducting test, I used the code my team mate Ömer Şafak Bebek provided for user authentication as below:

  • findLocation:

In the first one, I'm giving an IP address that doesn't exist, therefore it returns status code 500 internal server error. In the second one, I do not give an IP address, therefore it returns status code 400 which I defined in my location.controller.js file.

  • addLocation:

In the first one, the user is not logged in but trying to add a location, this returns 401 unauthorized error due to lack of access token. In the second one IP address is not provided, thus it returns status code 400 which I defined in my location.controller.js file.

  • /history:

!

The user is logged in and therefore there is email data. Thus, it returns status code 200.

!

In this one, the user is not logged in; therefore it returns a 401 error code.

Sample Calls

For successful calls to /addLocation and /history, I give an access token first. I'm using Swagger to display requests and responses (JSON, headers, status code).

  • /findLocation successful call

find location successful

  • /findLocation no ip_address

findLocation fail

  • /findLocation with unvalid ip_address

image

  • /addLocation successful call

image

  • /addLocation without authorization

image

  • /history successful call

Adsız

  • /history without authorization

image

Other Significant Work

I made the frontend (client) folder structure and prepared the landing page which includes 10 buttons navigating to my teammates' pages. Inside the client folder, I created a pages segment and created a separate folder for each teammate. In the landing page, I connected the files in these folders with the buttons. Also, I added a header part which also includes the contributors sidebar, GitHub icon navigating to our GitHub repository. I added a background image.

Challenges

I don't have any experience on the backend and frontend, therefore almost any of them were a new experience for me. I struggled a lot but tried to do my best.