This API provides endpoints for handling location-based services, including collecting GPS coordinates, calculating distances between coordinates, finding the closest recorded location, and managing user authentication.
- Endpoint:
/api/coordinates
- Method:
GET
- Description: Get Random Coordinates.
- Response: Returns a Random Coordinate.
- Endpoint:
/api/location
- Method:
POST
- Description: Collect GPS coordinates by providing latitude and longitude.
- Authorization: Bearer token required.
- Request Body:
{ "latitude": 37.7749, "longitude": -122.4194 }
- Response: Returns the created location details.
- Endpoint:
/api/distance
- Method:
POST
- Description: Calculate the Haversine distance between two sets of coordinates.
- Authorization: Bearer token required.
- Request Body:
{ "coordinate1": { "latitude": 37.7749, "longitude": -122.4194 }, "coordinate2": { "latitude": 37.7749, "longitude": -122.4194 } }
- Response: Returns the calculated Haversine distance in meters.
- Endpoint:
/api/closest
- Method:
POST
- Description: Find the closest recorded location to a given point.
- Authorization: Bearer token required.
- Request Body:
{ "latitude": 37.7749, "longitude": -122.4194 }
- Response: Returns the closest recorded location details.
-
Install dependencies:
npm install
-
Start the server:
npm start
-
Open Swagger UI:
http://localhost:3000/api-docs
- JWT Authentication: User authentication is implemented using JWT tokens. Endpoints requiring authorization expect a Bearer token in the request header.
- User Endpoints: User endpoints for authentication, such as login and registration, are available.