Run npm install in the git repo to install the necessary modules.
To start node, run nodemon index.js.
Create a MongoDB called canineCompass and a collection called dogWalks. Now import db/dogWalks.json into MongoDB Compass
Adds a single new walk into the dogWalks collection
-
URL:
/walks
-
Method:
POST
-
Data Params
Required:
{
"name": [string],
"length": [integer],
"startInstructions": [string],
"difficulty": [integer],
"markersArray": [
{
"lat": [number],
"lng": [number]
}
]
};
-
Success Response:
- Code: 201
Content:{ "success": true, "message": "New walk added!" }
- Code: 201
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "success": false, "message": "Validation failed :( Check your input!" }
OR
- Code: 400 BAD REQUEST
Content:{ "success": false, "message": "Something went wrong!" }
- Code: 400 BAD REQUEST
-
Sample Call:
fetch('http://localhost:3000/walks', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: "Nova's Walk",
length: 40,
difficulty: 3,
startInstructions: "Go left over the stile",
markersArray: [{
lat: 8.12132522887685,
lng: -14.5299704759841
}]
})
})
Returns an array of all markers currently in the database.
-
URL:
/markers
-
Method:
GET
-
Success Response:
- Code: 201
Content: { success: true, message: 'Successfully found markers', data: [{ walkName: 'Novas Walk', markersObject: { lat: 8.1213, lng: -14.529 }, id: new ObjectId("XXX") }
- Code: 201
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ success: false, message: 'No markers returned :(', data: [] }
- Code: 400 BAD REQUEST
-
Sample Call:
fetch('http://localhost:3000/markers', {
method: 'GET',
headers: {'Content-Type': 'application/json'}
})