Coder Social home page Coder Social logo

location_service's Introduction

Location-based Service API

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.

API Endpoints

Get Random Coordinates

  • Endpoint: /api/coordinates
  • Method: GET
  • Description: Get Random Coordinates.
  • Response: Returns a Random Coordinate.

Collect GPS Coordinates

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

Calculate Distance

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

Find Closest Location

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

How to Start

  1. Install dependencies:

    npm install
  2. Start the server:

    npm start
  3. Open Swagger UI:

    http://localhost:3000/api-docs
    

Extra Features

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

location_service's People

Contributors

agrim-ani avatar dkachhot21 avatar

Watchers

 avatar

Forkers

dkachhot21

location_service's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.