Reviewed-on: #11 Co-authored-by: Clement <c.boesmier@aptatio.com> Co-committed-by: Clement <c.boesmier@aptatio.com>
167 lines
4.4 KiB
TypeScript
167 lines
4.4 KiB
TypeScript
import { getCity, getRadius, getPoiId, getBox } from "./openTripMaps"
|
|
import express from "express"
|
|
/**
|
|
* Initialize Express application instance.
|
|
* @returns An initialized Express application object.
|
|
*/
|
|
const app = express()
|
|
|
|
|
|
|
|
/**
|
|
* Handle GET request for homepage route ('/welcome').
|
|
* Send back a simple json response.
|
|
* @param {express.Request} req - HTTP Request object.
|
|
* @param {express.Response} res - HTTP Response object.
|
|
*/
|
|
function getWelcome(req: express.Request, res: express.Response) {
|
|
const out = {hello:"world"}
|
|
res.send(out)
|
|
}
|
|
|
|
/**
|
|
* @openapi
|
|
* /welcome:
|
|
* get:
|
|
* summary: retun just hello
|
|
* description: Welcome to swagger-jsdoc!
|
|
* responses:
|
|
* 200:
|
|
* description: Returns a welcome json.
|
|
*/
|
|
app.get("/welcome", getWelcome)
|
|
|
|
/**
|
|
* @openapi
|
|
* /otm/city:
|
|
* get:
|
|
* summary: return the drinks in a city
|
|
* description: return the drinks in a defined perimeter in a city
|
|
* parameters:
|
|
* - name: name
|
|
* in: query
|
|
* required: true
|
|
* description: the name of the city
|
|
* 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/city", getCity)
|
|
|
|
|
|
/**
|
|
* @openapi
|
|
* /otm/radius:
|
|
* get:
|
|
* summary: return the drinks in a radius
|
|
* description: return the drinks in a defined radius
|
|
* parameters:
|
|
* - name: lon
|
|
* in: query
|
|
* required: true
|
|
* description: longitude of the center of the radius
|
|
* schema:
|
|
* type: number
|
|
* minimum: -180
|
|
* maximum: 180
|
|
* - name: lat
|
|
* in: query
|
|
* required: true
|
|
* description: latitude of the center of the radius
|
|
* schema:
|
|
* type: number
|
|
* minimum: -90
|
|
* maximum: 90
|
|
* - name: radius
|
|
* in: query
|
|
* description: size of the radius
|
|
* 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/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 the detaill of an POI in otm
|
|
* 400:
|
|
* description: Missing Argument Error
|
|
* 401:
|
|
* description: Missing OTM tocken
|
|
*/
|
|
app.get("/otm/poidetaill", getPoiId)
|
|
|
|
/**
|
|
* @openapi
|
|
* /otm/box:
|
|
* get:
|
|
* summary: return the drinks in a box
|
|
* description: return the drinks in a defined box
|
|
* parameters:
|
|
* - name: lon1
|
|
* in: query
|
|
* required: true
|
|
* description: longitude 1 of the box
|
|
* schema:
|
|
* type: number
|
|
* minimum: -180
|
|
* maximum: 180
|
|
* - name: lat1
|
|
* in: query
|
|
* required: true
|
|
* description: latitude 1 of the box
|
|
* schema:
|
|
* type: number
|
|
* minimum: -90
|
|
* maximum: 90
|
|
* - name: lon2
|
|
* in: query
|
|
* required: true
|
|
* description: longitude 2 of the box
|
|
* schema:
|
|
* type: number
|
|
* minimum: -180
|
|
* maximum: 180
|
|
* - name: lat2
|
|
* in: query
|
|
* required: true
|
|
* description: latitude 2 of the box
|
|
* schema:
|
|
* type: number
|
|
* minimum: -90
|
|
* maximum: 90
|
|
* 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/box", getBox)
|
|
|
|
export default app |