feat: use drink api in front and more (#16)
All checks were successful
Build Docker Image Front / run (push) Successful in 28s
Build Docker Image Back / run (push) Successful in 27s

Reviewed-on: #16
Co-authored-by: Clement <c.boesmier@aptatio.com>
Co-committed-by: Clement <c.boesmier@aptatio.com>
This commit is contained in:
2024-06-07 19:09:57 +02:00
committed by Clement
parent 2cb2166093
commit 3cb5a30270
36 changed files with 882 additions and 132 deletions

View File

@ -1,11 +1,13 @@
import { getCity, getRadius, getPoiId, getBox } from "./openTripMaps"
import express from "express"
import cors from "cors"
/**
* Initialize Express application instance.
* @returns An initialized Express application object.
*/
const app = express()
app.use(cors())
/**

View File

@ -13,7 +13,7 @@ const key = process.env.OPEN_TRIP_MAPS_KEY
* @param {string} lat2 Latitude of the 2nd point of the box
* @returns {FeatureCollection} a list of POIs with their type, id, etc. (cf: [opentripmap](https://dev.opentripmap.org/docs#))
*/
async function callBox(lon1:string, lat1:string, lon2: string, lat2: string) {
async function callBox(lon1:string, lat1:string, lon2: string, lat2: string, rate: string) {
const lonMin = Math.min(parseFloat(lon1), parseFloat(lon2))
const lonMax = Math.max(parseFloat(lon1), parseFloat(lon2))
const latMin = Math.min(parseFloat(lat1), parseFloat(lat2))
@ -27,6 +27,7 @@ async function callBox(lon1:string, lat1:string, lon2: string, lat2: string) {
lon_max: lonMax,
lat_min: latMin,
lat_max: latMax,
rate: rate,
apikey: key,
kinds: 'bars,cafes,pubs,biergartens'
},
@ -182,11 +183,16 @@ export async function getBox(req:express.Request, res: express.Response) {
const lat1 = req.query["lat1"] as string
const lon2 = req.query["lon2"] as string
const lat2 = req.query["lat2"] as string
let rate = req.query["rate"] as string
if(!lon1 || !lat1 || !lon2 || !lat2){
res.status(400).send("Missing Argument")
return
}
res.send( await callBox(lon1, lat1, lon2, lat2))
if(!rate){
rate = "1";
}
res.send( await callBox(lon1, lat1, lon2, lat2, rate))
}

View File

@ -21,7 +21,7 @@ const options = {
}
],
},
apis: ['./src/*.ts'],
apis: ['./src/*.ts','./dist/src/*.js'],
explorer: true
}