/** * @swagger * tags: * name: Places * description: Access to the Google Place API via the Key used in backend. Only for manual use in the prototype application! */ const router = require("express").Router() // Models const getPlace = require("../models/getPlace.js") const getPlaceNearby = require("../models/getPlaceNearby.js") const getPlacePhoto = require("../models/getPlacePhoto.js") // Utils const sqlSanitzer = require("../util/sqlstring_sanitizer.js") module.exports = dbConn => { /** * @swagger * /place: * get: * summary: Get a specific place * tags: [Places] * parameters: * - name: "q" * in: "query" * required: true * type: int * description: "Querystring, by which the place is searched" * example: Berlin * responses: * "200": * description: Returns a place from the google places API. */ router.get("/api/v1/place", async (req, res) => { const place = await getPlace(req.query.q) res.json(place) }); /** * @swagger * /place/nearby: * get: * summary: Get nearby touristic places * tags: [Places] * parameters: * - name: "lat" * in: "query" * required: true * type: float * description: "Latitiude" * example: 52.520365 * - name: "lng" * in: "query" * required: true * type: float * description: "Longitude" * example: 13.403509 * responses: * "200": * description: Returns nearby places from the google places API. */ router.get("/api/v1/place/nearby", async (req, res) => { const lat = req.query.lat const lng = req.query.lng const place = await getPlaceNearby(lat, lng) res.json(place) }); /** * @swagger * /place/photo: * get: * summary: Get a photo for a place * tags: [Places] * parameters: * - name: "photoref" * in: "query" * required: true * type: int * description: "Photo_Reference which is returned for a place by Google Places API" * example: CmRaAAAAbupojmH94negtiCnLGdfx2azxhVTEDI1rtTrYnQ7KclEI-Yy9_YGxN9h63AKrCzd22kk5z-UiK7fS4-zXnO5OqfNRZu2hrmfcp8b77rItediibAVovOOA5LnyJ9YYuofEhAAr0Im0zuiAtbDKPjbPUSBGhTFkSrH6FZxenbo1bCkdCXaUMhOug * responses: * "200": * description: Returns the matching url to the photo. */ router.get("/api/v1/place/photo", async (req, res) => { const photoref = req.query.photoref const photo = await getPlacePhoto(photoref) res.json(photo) }); return router; };