feat: open-trip-api-drink #11

Merged
Clement merged 34 commits from feat/open-trip-api into master 2024-05-19 09:38:39 +00:00
Showing only changes of commit 9ac4ba7252 - Show all commits

View File

@ -58,6 +58,28 @@ async function callCity(name:string) {
}
}
/**
* make GET request to the OTM for city info.
* @param {string} name Name of a city
* @returns {Geoname} info of a search city their name, country, lat, lon, etc. (cf: [opentripmap](https://dev.opentripmap.org/docs#))
*/
async function callId(id:string) {
const optionsId = {
method: 'GET',
url: 'https://api.opentripmap.com/0.1/en/places/xid/' + id,
params: {
apikey: key
},
headers: {'Content-Type': 'application/json'}
};
try {
const { data } = await axios.request(optionsId);
return data
} catch (error) {
console.error(error);
}
}
/**
* Handle GET request for city search route ('/otm/city').
@ -99,5 +121,19 @@ export async function getRadius(req:express.Request, res: express.Response) {
res.send( await callRadius(lon,lat,radius as string))
}
/**
* Handle GET request for radius search route ('/otm/radius').
* @param {express.Request} req - HTTP Request object.
* @param {express.Response} res - HTTP Response object.
*/
export async function getPoiId(req: express.Request, res: express.Response){
const id = req.query["id"] as string
if(!id){
res.status(400).send("Missing Argument name")
return
}
res.send( await callId( id as string))
}
//TODO: fair une route ou l'on donne l'id un établicement pour avoir des détailles
//TODO: fair une route ou l'on donne 2 coordonée