-
Food Truck Location REST API -
- Given a valid location (latitude & longitude), we calculate the distance to all the food trucks. The result is sorted by distance.
- Only the facilities with 'APPROVED' Status and 'Truck' FacilityType are queried.
- The default number of locations returned is 5, but the limit can be modified.
- In order to calculate a distance, we use a NodeJS library that implements Haversine's formula (see more on Wikipedia)
-
Example calls
curl --location --request GET 'http://localhost:3000/food-truck/find?latitude=37.77&longitude=-122.3'
curl --location --request GET 'http://localhost:3000/food-truck/find?latitude=37.77&longitude=-122.3&limit=10'
Developer's Guide:
- install nodeJS from https://nodejs.org/en/download/
- Make sure that port 3000 is available on you machine, or change the
PORT
constant in theapp.js
file - From the root folder, run
npm install
- To make sure everything is fine, run the unit-tests with
npm test
- Start the application with
npm start
- Run one of the example calls from Postman or the terminal
- A good place to start looking at the code is in
app.js