118 lines
3.1 KiB
TypeScript
118 lines
3.1 KiB
TypeScript
import { getCity, getRadius, getPoiId } 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 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 |