Compare commits

..

No commits in common. "ae9e1eae47245aeaeb76b328fb227b082a75c8ee" and "4e2803fcdbbaa4732cac91533d83af52f04fa0cf" have entirely different histories.

5 changed files with 1 additions and 145 deletions

View File

@ -1,4 +1,4 @@
import { getCity, getRadius, getPoiId } from "./openTripMaps"
import { getCity, getRadius } from "./openTripMaps"
import express from "express"
/**
* Initialize Express application instance.
@ -91,28 +91,4 @@ app.get("/otm/city", getCity)
*/
app.get("/otm/radius", getRadius)
/**
* @openapi
* /otm/poidetaill:
* get:
* summary: detail of a POI
* description: detail of a POI link name, kind, rate,...
* parameters:
* - name: id
* in: query
* required: true
* description: Unique identifier of the object in OpenTripMap
* schema:
* type: string
* responses:
* 200:
* description: Return a list of bars and coffee in city in geoJSON format
* 400:
* description: Missing Argument Error
* 401:
* description: Missing OTM tocken
*/
app.get("/otm/poidetaill", getPoiId)
export default app

View File

@ -58,28 +58,6 @@ 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').
@ -121,19 +99,5 @@ 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

View File

@ -108,62 +108,4 @@ describe("Test the otm city path", () => {
});
})
test("It should response the 200 code for GET method", done => {
request(app)
.get("/otm/poidetaill")
.query({'id':'562635'})
.then(response => {
expect(response.statusCode).toBe(200);
done();
});
});
test("Get bar in radius from API", done => {
const out = {
"xid": "N4032296324",
"name": "Le 27 point carré",
"address": {
"road": "Rue Raymond Poincaré",
"town": "La Roche-sur-Yon",
"state": "Pays de la Loire",
"county": "La Roche-sur-Yon",
"suburb": "Zola",
"country": "France",
"postcode": "85000",
"country_code": "fr",
"house_number": "27",
"neighbourhood": "Cité des Forges"
},
"rate": "1",
"osm": "node/4032296324",
"kinds": "foods,bars,tourist_facilities",
"sources": {
"geometry": "osm",
"attributes": [
"osm"
]
},
"otm": "https://opentripmap.com/en/card/N4032296324",
"point": {
"lon": -1.4344594478607178,
"lat": 46.66864776611328
}
}
request(app)
.get("/otm/poidetaill")
.query({'id':'562635'})
.then(response => {
expect(response.text).toEqual(JSON.stringify(out));
done();
});
})
test("It should response the 200 code for GET method", done => {
request(app)
.get("/otm/poidetaill")
.then(response => {
expect(response.statusCode).toBe(400);
done();
});
});
});

View File

@ -1,11 +0,0 @@
meta {
name: get return format
type: http
seq: 11
}
get {
url: https://dev.opentripmap.org/openapi.en.json
body: none
auth: none
}

View File

@ -1,15 +0,0 @@
meta {
name: otm_ex_drink_id
type: http
seq: 10
}
get {
url: https://api.opentripmap.com/0.1/en/places/xid/562635?apikey={{OTM_KEY}}
body: none
auth: none
}
query {
apikey: {{OTM_KEY}}
}