Skip to content

Member Contribution Report (Elif Kızılkaya)

Elif Kizilkaya edited this page May 12, 2023 · 13 revisions

Important Issues Related to the Practice Application

  • #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
  • #173: Constructing the frontend project (aka. client folder)
  • #185: Frontend for Landing page- Home Page
  • #198: Described my frontend views for my functions

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.

  • 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}

  • 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}

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.

Sample Calls

  • /findLocation successful call

  • /findLocation no ip_address

  • /findLocation with unvalid ip_address

  • /addLocation successful call

  • /addLocation without authorization

  • /history of successful call

  • /history without authorization

Other Significant Work

Challenges

Welcome to the Wiki Page of Group 7! 👋

🏠 Home

📦 Deliverables

👥 Who We Are

Former Team Members

Github Repository & API Researches
Chosen Researches by Our Team

📃 Templates

Templates

📓 Meeting Notes

Meeting Notes of 352
Meeting Notes of 451
Frontend Team Meeting Notes
Backend Team Meeting Notes
Mobile Team Meeting Notes

👀 Requirements

📈 Diagrams

🛠️ User Scenarios and Mockups

Clone this wiki locally