Skip to content

This Api compares results returned by ‘Haversine’ formula and MongoDB Geospatial Indexes.

Notifications You must be signed in to change notification settings

divyanshu-rawat/haversine-rest-api

Repository files navigation

Built a rest Api in Node.js by leveraging Node.js

Greenkeeper badge

forthebadge forthebadge forthebadge

Contact me on Codementor Twitter URL

Say Thanks! Build Status

Back-End API

  • https://myrestfulapplication.herokuapp.com/api/users
  • Please Use POSTMAN for Testing Purpose !!
  • Authenticate Client First
  • Username : divyanshu
  • Password : xyz
  • A JWT will be generated and used for subsequent request from Client to server !
  • You can register as well no need to rely on username : divyanshu !!

Description

  • This Api compares results returned by ‘Haversine’ formula and MongoDB Geospatial Indexes and Queries feature.
  • when a location is given and we need to fetch all the nearby points within a radius.
  • Used JSON web tokens for token-based user authentication.
  • Used ‘Haversine’ formula to calculate distance between given (Latitude,longitude) pairs.
  • This Api compares results returned by ‘Haversine’ formula and MongoDB Geospatial Indexes and Queries feature.

How it works !

Api Consist of following End Points


  	app.post('/post_location',callback.post_location);

	app.get('/get_location',callback.get_location);

	app.get('/',callback.basic_route);

	app.post('/register',callback.register_user);

	app.get('/users',callback.get_users);

	app.post('/get_using_self',callback.get_using_self);
	
	app.post('/get_using_self',callback.get_using_mongodb

Installation Instructions ❕

  • Clone or download the repo. into any fresh temporary folder.

  • Cd into that root folder you just cloned locally.

  • Open terminal in the current folder and to install all dependencies type

   npm install 
  • Now typing
   nodemon server.js
  • will start a server !

DB Used (MongoDB)

  • MLab's MongoDB hosting platform is the fastest growing cloud Database-as-a-Service in the world. Get started with a free database and expert support.

Package Manager Used (NPM)

  • NPM is the default package manager for the JavaScript runtime environment Node.js.

Package.json (dependencies)

  • For dependencies refer Package.json.

For Testing (Postman)

  • Postman extension can be used for testing !
  • Supercharge your API workflow with Postman! Build, test, and document your APIs faster.
  • You can now fire up postman and then perform several operations on the REST API.

Contributing

  1. Create your branch: git checkout -b my-new-feature

  2. Commit your changes: git commit -m 'Add some feature'

  3. Push to the branch: git push origin my-new-feature

  4. Send a Pull Request

  5. Enjoy!

Examples

alt tag

alt tag

Comparison between Haversine Formula v/s Mongodb Geospatial

  • Sample Data via Postman
	{"radius":"10","coordinates":[38.8,-77.0]} Data Format - [lat,long]
  • POST Request to URL localhost:4000/api/get_using_self

alt tag

  • POST Request to URL localhost:4000/api/get_using_mongodb

alt tag

About

This Api compares results returned by ‘Haversine’ formula and MongoDB Geospatial Indexes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published