diff --git a/src/App.js b/src/App.js index cdee87039111e29bee074d1873db8844d36f6acc..413a26afdaf8c4177c191f9c9b945fa6426a1d6a 100644 --- a/src/App.js +++ b/src/App.js @@ -50,25 +50,6 @@ app.get('/parking-locations', async (request, response) => { } }); - - -// // function focused on finding nearby parking based on radius -// app.get('/parking-locations/:postcode', async (request, response) => { -// try { -// const postcode = request.params.postcode; -// const url = `https://api.postcodes.io/postcodes/${encodeURIComponent(postcode)}`; -// const { data } = await axios.get(url); -// const { latitude, longitude } = data.result; -// console.log(`ðŸŒ: Successfully retrieved latitude ${latitude} and longitude ${longitude} from postcode ${postcode}.`); -// response.send({ latitude, longitude }); -// } catch (error) { -// console.error(`Error retrieving latitude and longitude from postcode ${postcode}: ${error.message}`); -// response.status(500).send(`Error retrieving latitude and longitude from postcode ${postcode}: ${error.message}`); -// } -// }); - - - function isAdmin(request, response, next) { const authHeader = request.headers.authorization; const token = authHeader && authHeader.split(' ')[1]; @@ -95,10 +76,9 @@ app.post('/parking-locations', isAdmin, async (request, response) => { try { const { Title, Description,city, street_address, postcode, lat, lon, spaces_available, total_spaces } = request.body; - // Check if street_address already exists in the database const existingLocation = await ParkingLocation.findOne({ street_address }); if (existingLocation) { - return response.status(400).json({ error: 'â›”ï¸: A parking location with this street address already exists.' }); + return response.status(400).json({ error: 'â›”ï¸: A parking location with this street address already exists. Please try another alternative location. ' }); } const parkingLocation = new ParkingLocation({ @@ -120,8 +100,6 @@ app.post('/parking-locations', isAdmin, async (request, response) => { response.status(500).json({ error: 'â›”ï¸: Failed to add parking to database, please try again later.' }); } }); - - app.delete('/parking-locations/:id', isAdmin, async (request, response) => {