- npm install
- npm test
- npm start
- Node.js : v10.16.3
localhost:3030/api/v1/closest?zip=
localhost:3030/api/v1/closest?address=
localhost:3030/api/v1/closest?zip=&units=<(mi|km)>
localhost:3030/api/v1/closest?zip=10003
localhost:3030/api/v1/closest?zip=10003&units=km
First I need to explain about Formula that I used in my code which is haversine
haversine : The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. Important in navigation, it is a special case of a more general formula in spherical trigonometry, the law of haversines, that relates the sides and angles of spherical triangles.
So , the idea is using haversine formula to get distance between the requested address and the stores then sort elements descending and getting the first element