Changed to better JSDoc Syntax
This commit is contained in:
parent
4fa241ad60
commit
531f133875
@ -14,7 +14,6 @@ const port = process.env.PORT
|
|||||||
const search = require("./routes/search");
|
const search = require("./routes/search");
|
||||||
const regions = require("./routes/regions");
|
const regions = require("./routes/regions");
|
||||||
const countries = require("./routes/countries");
|
const countries = require("./routes/countries");
|
||||||
const climate = require("./routes/climate");
|
|
||||||
const places = require("./routes/place");
|
const places = require("./routes/place");
|
||||||
const update = require("./routes/update");
|
const update = require("./routes/update");
|
||||||
|
|
||||||
@ -70,13 +69,12 @@ const swaggerDocs = swaggerJsdoc(swaggerOptions);
|
|||||||
app.use(express.static(path.join(__dirname, "../../dist")));
|
app.use(express.static(path.join(__dirname, "../../dist")));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use('/api/v1/doc', swaggerUi.serve, swaggerUi.setup(swaggerDocs, {explorer: true}));
|
app.use('/api/v1/doc', swaggerUi.serve, swaggerUi.setup(swaggerDocs, {explorer: false, docExpansion: "list"}));
|
||||||
|
|
||||||
// Express routes
|
// Express routes
|
||||||
app.use(search(dbConn));
|
app.use(search(dbConn));
|
||||||
app.use(regions(dbConn));
|
app.use(regions(dbConn));
|
||||||
app.use(countries(dbConn));
|
app.use(countries(dbConn));
|
||||||
app.use(climate(dbConn));
|
|
||||||
app.use(places(dbConn));
|
app.use(places(dbConn));
|
||||||
app.use(update(dbConn))
|
app.use(update(dbConn))
|
||||||
|
|
||||||
|
|||||||
6
backend/package-lock.json
generated
6
backend/package-lock.json
generated
@ -1626,9 +1626,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"swagger-ui-dist": {
|
"swagger-ui-dist": {
|
||||||
"version": "3.27.0",
|
"version": "3.28.0",
|
||||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.27.0.tgz",
|
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.28.0.tgz",
|
||||||
"integrity": "sha512-dlbH4L8+UslXVeYvCulicmJP2cnHLoabQGfeav5lx74fM+tMQW53M8iqpH5wbBqBbFkZwza+IIWoPrenqO/F2g=="
|
"integrity": "sha512-aPkfTzPv9djSiZI1NUkWr5HynCUsH+jaJ0WSx+/t19wq7MMGg9clHm9nGoIpAtqml1G51ofI+I75Ym72pukzFg=="
|
||||||
},
|
},
|
||||||
"swagger-ui-express": {
|
"swagger-ui-express": {
|
||||||
"version": "4.1.4",
|
"version": "4.1.4",
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* tags:
|
|
||||||
* name: Climate
|
|
||||||
* description: Climate data acquiration
|
|
||||||
*/
|
|
||||||
|
|
||||||
const router = require("express").Router()
|
|
||||||
|
|
||||||
// Models
|
|
||||||
const handleClimateUpdate = require("../models/handleClimateUpdate.js")
|
|
||||||
const handleClimateUpdateV2 = require("../models/handleClimateUpdateV2.js")
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = dbConn => {
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* path:
|
|
||||||
* /climate/update:
|
|
||||||
* patch:
|
|
||||||
* summary: Pull monthly data from meteostat API V1
|
|
||||||
* tags: [Climate]
|
|
||||||
* responses:
|
|
||||||
* "200":
|
|
||||||
* description: Update information is logged in backend
|
|
||||||
*/
|
|
||||||
router.patch("/api/v1/climate/update", async (req, res) => {
|
|
||||||
const update = await handleClimateUpdate(dbConn)
|
|
||||||
res.json(update)
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* path:
|
|
||||||
* /climate/update/v2:
|
|
||||||
* patch:
|
|
||||||
* summary: Pull daily data from meteostat API V2
|
|
||||||
* tags: [Climate]
|
|
||||||
* responses:
|
|
||||||
* "200":
|
|
||||||
* description: Update information is logged in backend
|
|
||||||
*/
|
|
||||||
router.patch("/api/v1/climate/update/v2", async (req, res) => {
|
|
||||||
const update = await handleClimateUpdateV2(dbConn)
|
|
||||||
res.json(update)
|
|
||||||
});
|
|
||||||
|
|
||||||
return router;
|
|
||||||
};
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Countries
|
* name: Countries
|
||||||
* description: Access country data
|
* description: Access country data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const router = require("express").Router();
|
const router = require("express").Router();
|
||||||
@ -40,9 +40,11 @@ module.exports = dbConn => {
|
|||||||
* in: "path"
|
* in: "path"
|
||||||
* required: true
|
* required: true
|
||||||
* type: int
|
* type: int
|
||||||
|
* example: 23
|
||||||
* responses:
|
* responses:
|
||||||
* "200":
|
* "200":
|
||||||
* description: Returns aviable data for the country
|
* description: Returns aviable data for the country
|
||||||
|
* example: test
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/countries/:id", async (req, res) => {
|
router.get("/api/v1/countries/:id", async (req, res) => {
|
||||||
const id = sqlSanitzer(req.params.id);
|
const id = sqlSanitzer(req.params.id);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Places
|
* name: Places
|
||||||
* description: Access to the Google Place API
|
* 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()
|
const router = require("express").Router()
|
||||||
@ -28,6 +28,7 @@ module.exports = dbConn => {
|
|||||||
* required: true
|
* required: true
|
||||||
* type: int
|
* type: int
|
||||||
* description: "Querystring, by which the place is searched"
|
* description: "Querystring, by which the place is searched"
|
||||||
|
* example: Berlin
|
||||||
* responses:
|
* responses:
|
||||||
* "200":
|
* "200":
|
||||||
* description: Returns a place from the google places API.
|
* description: Returns a place from the google places API.
|
||||||
@ -49,11 +50,13 @@ module.exports = dbConn => {
|
|||||||
* required: true
|
* required: true
|
||||||
* type: float
|
* type: float
|
||||||
* description: "Latitiude"
|
* description: "Latitiude"
|
||||||
|
* example: 52.520365
|
||||||
* - name: "lng"
|
* - name: "lng"
|
||||||
* in: "query"
|
* in: "query"
|
||||||
* required: true
|
* required: true
|
||||||
* type: float
|
* type: float
|
||||||
* description: "Longitude"
|
* description: "Longitude"
|
||||||
|
* example: 13.403509
|
||||||
* responses:
|
* responses:
|
||||||
* "200":
|
* "200":
|
||||||
* description: Returns nearby places from the google places API.
|
* description: Returns nearby places from the google places API.
|
||||||
@ -65,21 +68,6 @@ module.exports = dbConn => {
|
|||||||
res.json(place)
|
res.json(place)
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* path:
|
|
||||||
* /place/photo:
|
|
||||||
* get:
|
|
||||||
* summary: Get a photo for a place
|
|
||||||
* tags: [Places]
|
|
||||||
* responses:
|
|
||||||
* "200":
|
|
||||||
* description: Returns the matching photo for a photo_reference.
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: ''
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /place/photo:
|
* /place/photo:
|
||||||
@ -92,9 +80,10 @@ module.exports = dbConn => {
|
|||||||
* required: true
|
* required: true
|
||||||
* type: int
|
* type: int
|
||||||
* description: "Photo_Reference which is returned for a place by Google Places API"
|
* description: "Photo_Reference which is returned for a place by Google Places API"
|
||||||
|
* example: CmRaAAAAbupojmH94negtiCnLGdfx2azxhVTEDI1rtTrYnQ7KclEI-Yy9_YGxN9h63AKrCzd22kk5z-UiK7fS4-zXnO5OqfNRZu2hrmfcp8b77rItediibAVovOOA5LnyJ9YYuofEhAAr0Im0zuiAtbDKPjbPUSBGhTFkSrH6FZxenbo1bCkdCXaUMhOug
|
||||||
* responses:
|
* responses:
|
||||||
* "200":
|
* "200":
|
||||||
* description: Returns the matching photo for a photo_reference.
|
* description: Returns the matching url to the photo.
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/place/photo", async (req, res) => {
|
router.get("/api/v1/place/photo", async (req, res) => {
|
||||||
const photoref = req.query.photoref
|
const photoref = req.query.photoref
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Regions
|
* name: Regions
|
||||||
* description: Access region data
|
* description: Access region data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const router = require("express").Router();
|
const router = require("express").Router();
|
||||||
@ -27,7 +27,7 @@ module.exports = dbConn => {
|
|||||||
* tags: [Regions]
|
* tags: [Regions]
|
||||||
* responses:
|
* responses:
|
||||||
* "200":
|
* "200":
|
||||||
* description: Returns aviable data for all regions
|
* description: Returns available data for all regions
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/regions", async (req, res) => {
|
router.get("/api/v1/regions", async (req, res) => {
|
||||||
const data = await getRegions(dbConn)
|
const data = await getRegions(dbConn)
|
||||||
@ -52,7 +52,7 @@ module.exports = dbConn => {
|
|||||||
* type: int
|
* type: int
|
||||||
* responses:
|
* responses:
|
||||||
* "200":
|
* "200":
|
||||||
* description: Returns aviable data for the region
|
* description: Returns available data for the region
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/regions/:id", async (req, res) => {
|
router.get("/api/v1/regions/:id", async (req, res) => {
|
||||||
console.log(typeof req.params.id)
|
console.log(typeof req.params.id)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Search
|
* name: Search
|
||||||
* description: Access the information for the search
|
* description: Access the search algorithm and the data provided for searching.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const router = require("express").Router();
|
const router = require("express").Router();
|
||||||
@ -21,52 +21,44 @@ const { getUniqueTags } = require("../models/getTags.js");
|
|||||||
module.exports = dbConn => {
|
module.exports = dbConn => {
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /search:
|
||||||
* /search:
|
* get:
|
||||||
* get:
|
* summary: Get Searchresults
|
||||||
* summary: Get Searchresults
|
* tags: [Search]
|
||||||
* tags: [Search]
|
* parameters:
|
||||||
* responses:
|
* - name: "q"
|
||||||
* "200":
|
* in: "query"
|
||||||
* description: Returns the region information and scores for the searchresults
|
* required: true
|
||||||
* content:
|
* type: int
|
||||||
* application/json:
|
* description: "Base64 encoded JS-Object with searchparameters"
|
||||||
* schema:
|
* example: eyJmcm9tIjoxNTkzNjQ4MDAwMDAwLCJ0byI6MTU5NDI1MjgwMDAwMCwidGFncyI6W119
|
||||||
* $ref: ''
|
* responses:
|
||||||
|
* "200":
|
||||||
|
* description: Returns the region information and scores for the searchresults
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/search", searchHandler(dbConn));
|
router.get("/api/v1/search", searchHandler(dbConn));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /search/presets:
|
||||||
* /search/presets:
|
* get:
|
||||||
* get:
|
* summary: Get the presets for the search parameters
|
||||||
* summary: Get the presets for the search parameters
|
* tags: [Search]
|
||||||
* tags: [Search]
|
* responses:
|
||||||
* responses:
|
* "200":
|
||||||
* "200":
|
* description: Returns all presets for the search parameters
|
||||||
* description: Returns all presets for the search parameters
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: ''
|
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/search/presets", presetHandler(dbConn));
|
router.get("/api/v1/search/presets", presetHandler(dbConn));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /search/tags:
|
||||||
* /search/tags:
|
* get:
|
||||||
* get:
|
* summary: Get the existing searchtags
|
||||||
* summary: Get the existing searchtags
|
* tags: [Search]
|
||||||
* tags: [Search]
|
* responses:
|
||||||
* responses:
|
* "200":
|
||||||
* "200":
|
* description: Returns all existing searchtags
|
||||||
* description: Returns all existing searchtags
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: ''
|
|
||||||
*/
|
*/
|
||||||
router.get("/api/v1/search/tags", tagsHandler(dbConn));
|
router.get("/api/v1/search/tags", tagsHandler(dbConn));
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,14 @@
|
|||||||
* @swagger
|
* @swagger
|
||||||
* tags:
|
* tags:
|
||||||
* name: Update
|
* name: Update
|
||||||
* description: Endpoint for updating region specific data
|
* description: Endpoint for updating region specific data. Only for manual use in the prototype application!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const router = require("express").Router();
|
const router = require("express").Router();
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
|
const handleClimateUpdate = require("../models/handleClimateUpdate.js")
|
||||||
|
const handleClimateUpdateV2 = require("../models/handleClimateUpdateV2.js")
|
||||||
const handleUpdateRegionNearby = require("../models/handleUpdateRegionNearby.js")
|
const handleUpdateRegionNearby = require("../models/handleUpdateRegionNearby.js")
|
||||||
const handleUpdateRegionNearbyById = require("../models/handleUpdateRegionNearbyById.js")
|
const handleUpdateRegionNearbyById = require("../models/handleUpdateRegionNearbyById.js")
|
||||||
const handleUpdateRegionNearbyImgUrl = require("../models/handleUpdateRegionNearbyImgUrl.js")
|
const handleUpdateRegionNearbyImgUrl = require("../models/handleUpdateRegionNearbyImgUrl.js")
|
||||||
@ -19,18 +21,43 @@ const sqlSanitzer = require("../util/sqlstring_sanitizer.js")
|
|||||||
module.exports = dbConn => {
|
module.exports = dbConn => {
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /update/climate/v1:
|
||||||
* /update/regions/all/nearby:
|
* patch:
|
||||||
* patch:
|
* summary: Pull monthly data from meteostat API V2
|
||||||
* summary: Updates all nearby data for all regions
|
* tags: [Update]
|
||||||
* tags: [Update]
|
* responses:
|
||||||
* responses:
|
* "200":
|
||||||
* "200":
|
* description: Update information is logged in backend
|
||||||
* description: Updates all nearby data for all regions
|
*/
|
||||||
* content:
|
router.patch("/api/v1/update/climate/v1", async (req, res) => {
|
||||||
* application/json:
|
const update = await handleClimateUpdate(dbConn)
|
||||||
* schema:
|
res.json(update)
|
||||||
* $ref: ''
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /update/climate/v2:
|
||||||
|
* patch:
|
||||||
|
* summary: Pull daily data from meteostat API V2
|
||||||
|
* tags: [Update]
|
||||||
|
* responses:
|
||||||
|
* "200":
|
||||||
|
* description: Update information is logged in backend
|
||||||
|
*/
|
||||||
|
router.patch("/api/v1/update/climate/v2", async (req, res) => {
|
||||||
|
const update = await handleClimateUpdateV2(dbConn)
|
||||||
|
res.json(update)
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /update/regions/all/nearby:
|
||||||
|
* patch:
|
||||||
|
* summary: Updates all nearby data for all regions
|
||||||
|
* tags: [Update]
|
||||||
|
* responses:
|
||||||
|
* "200":
|
||||||
|
* description: Updates all nearby data for all regions
|
||||||
*/
|
*/
|
||||||
router.patch("/api/v1/update/regions/all/nearby", async (req, res) => {
|
router.patch("/api/v1/update/regions/all/nearby", async (req, res) => {
|
||||||
res.json(await handleUpdateRegionNearby(dbConn))
|
res.json(await handleUpdateRegionNearby(dbConn))
|
||||||
@ -38,18 +65,13 @@ module.exports = dbConn => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /update/regions/all/lonlat:
|
||||||
* /update/regions/all/lonlat:
|
* patch:
|
||||||
* patch:
|
* summary: Updates all coordinate data for all regions
|
||||||
* summary: Updates all coordinate data for all regions
|
* tags: [Update]
|
||||||
* tags: [Update]
|
* responses:
|
||||||
* responses:
|
* "200":
|
||||||
* "200":
|
* description: Updates all coordinate data for all regions
|
||||||
* description: Updates all coordinate data for all regions
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: ''
|
|
||||||
*/
|
*/
|
||||||
router.patch("/api/v1/update/regions/all/lonlat", async (req,res) => {
|
router.patch("/api/v1/update/regions/all/lonlat", async (req,res) => {
|
||||||
res.json(await handleRegionLonLat(dbConn))
|
res.json(await handleRegionLonLat(dbConn))
|
||||||
@ -57,37 +79,32 @@ module.exports = dbConn => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /update/regions/all/nearby/image:
|
||||||
* /update/regions/all/nearby/imgurl:
|
* patch:
|
||||||
* patch:
|
* summary: Updates the nearby image urls for all regions
|
||||||
* summary: Updates the nearby imgurls for all regions
|
* tags: [Update]
|
||||||
* tags: [Update]
|
* responses:
|
||||||
* responses:
|
* "200":
|
||||||
* "200":
|
* description: Updates the nearby image urls for all regions
|
||||||
* description: Updates the nearby imgurls for all regions
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: ''
|
|
||||||
*/
|
*/
|
||||||
router.patch("/api/v1/update/regions/all/nearby/imgurl", async (req, res) => {
|
router.patch("/api/v1/update/regions/all/nearby/image", async (req, res) => {
|
||||||
res.json(await handleUpdateRegionNearbyImgUrl(dbConn))
|
res.json(await handleUpdateRegionNearbyImgUrl(dbConn))
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /update/regions/{id}/nearby:
|
||||||
* /update/regions/:id/nearby:
|
* patch:
|
||||||
* patch:
|
* summary: Updates the nearby data for a specific region
|
||||||
* summary: Updates the nearby data for a specific region
|
* tags: [Update]
|
||||||
* tags: [Update]
|
* parameters:
|
||||||
* responses:
|
* - name: "id"
|
||||||
* "200":
|
* in: "path"
|
||||||
* description: Updates the nearby data for a specific region
|
* required: true
|
||||||
* content:
|
* type: int
|
||||||
* application/json:
|
* responses:
|
||||||
* schema:
|
* "200":
|
||||||
* $ref: ''
|
* description: Updates the nearby data for a specific region
|
||||||
*/
|
*/
|
||||||
router.patch("/api/v1/update/regions/:id/nearby", async (req, res) => {
|
router.patch("/api/v1/update/regions/:id/nearby", async (req, res) => {
|
||||||
const id = sqlSanitzer(req.params.id);
|
const id = sqlSanitzer(req.params.id);
|
||||||
@ -96,20 +113,20 @@ module.exports = dbConn => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* path:
|
* /update/regions/{id}/nearby/image:
|
||||||
* /update/regions/:id/nearby/imgurl:
|
* patch:
|
||||||
* patch:
|
* summary: Updates the nearby image urls for a specific region
|
||||||
* summary: Updates the nearby imgurls for a specific region
|
* tags: [Update]
|
||||||
* tags: [Update]
|
* parameters:
|
||||||
* responses:
|
* - name: "id"
|
||||||
* "200":
|
* in: "path"
|
||||||
* description: Updates the nearby imgurls for a specific region
|
* required: true
|
||||||
* content:
|
* type: int
|
||||||
* application/json:
|
* responses:
|
||||||
* schema:
|
* "200":
|
||||||
* $ref: ''
|
* description: Updates the nearby image urls for a specific region
|
||||||
*/
|
*/
|
||||||
router.patch("/api/v1/update/regions/:id/nearby/imgurl", async (req, res) => {
|
router.patch("/api/v1/update/regions/:id/nearby/image", async (req, res) => {
|
||||||
const id = sqlSanitzer(req.params.id);
|
const id = sqlSanitzer(req.params.id);
|
||||||
res.json(await handleUpdateRegionNearbyImgUrlById(dbConn, id))
|
res.json(await handleUpdateRegionNearbyImgUrlById(dbConn, id))
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user