118 lines
3.6 KiB
JavaScript
118 lines
3.6 KiB
JavaScript
/**
|
|
* @swagger
|
|
* tags:
|
|
* name: Update
|
|
* description: Endpoint for updating region specific data
|
|
*/
|
|
|
|
const router = require("express").Router();
|
|
|
|
// Models
|
|
const handleUpdateRegionNearby = require("../models/handleUpdateRegionNearby.js")
|
|
const handleUpdateRegionNearbyById = require("../models/handleUpdateRegionNearbyById.js")
|
|
const handleUpdateRegionNearbyImgUrl = require("../models/handleUpdateRegionNearbyImgUrl.js")
|
|
const handleUpdateRegionNearbyImgUrlById = require("../models/handleUpdateRegionNearbyImgUrlById.js")
|
|
|
|
// Utils
|
|
const sqlSanitzer = require("../util/sqlstring_sanitizer.js")
|
|
|
|
module.exports = dbConn => {
|
|
/**
|
|
* @swagger
|
|
* path:
|
|
* /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
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: ''
|
|
*/
|
|
router.patch("/api/v1/update/regions/all/nearby", async (req, res) => {
|
|
res.json(await handleUpdateRegionNearby(dbConn))
|
|
});
|
|
|
|
/**
|
|
* @swagger
|
|
* path:
|
|
* /update/regions/all/lonlat:
|
|
* patch:
|
|
* summary: Updates all coordinate data for all regions
|
|
* tags: [Update]
|
|
* responses:
|
|
* "200":
|
|
* description: Updates all coordinate data for all regions
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: ''
|
|
*/
|
|
router.patch("/api/v1/update/regions/all/lonlat", async (req,res) => {
|
|
res.json(await handleRegionLonLat(dbConn))
|
|
});
|
|
|
|
/**
|
|
* @swagger
|
|
* path:
|
|
* /update/regions/all/nearby/imgurl:
|
|
* patch:
|
|
* summary: Updates the nearby imgurls for all regions
|
|
* tags: [Update]
|
|
* responses:
|
|
* "200":
|
|
* 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) => {
|
|
res.json(await handleUpdateRegionNearbyImgUrl(dbConn))
|
|
});
|
|
|
|
/**
|
|
* @swagger
|
|
* path:
|
|
* /update/regions/:id/nearby:
|
|
* patch:
|
|
* summary: Updates the nearby data for a specific region
|
|
* tags: [Update]
|
|
* responses:
|
|
* "200":
|
|
* description: Updates the nearby data for a specific region
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: ''
|
|
*/
|
|
router.patch("/api/v1/update/regions/:id/nearby", async (req, res) => {
|
|
const id = sqlSanitzer(req.params.id);
|
|
res.json(await handleUpdateRegionNearbyById(dbConn, id))
|
|
});
|
|
|
|
/**
|
|
* @swagger
|
|
* path:
|
|
* /update/regions/:id/nearby/imgurl:
|
|
* patch:
|
|
* summary: Updates the nearby imgurls for a specific region
|
|
* tags: [Update]
|
|
* responses:
|
|
* "200":
|
|
* description: Updates the nearby imgurls for a specific region
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: ''
|
|
*/
|
|
router.patch("/api/v1/update/regions/:id/nearby/imgurl", async (req, res) => {
|
|
const id = sqlSanitzer(req.params.id);
|
|
res.json(await handleUpdateRegionNearbyImgUrlById(dbConn, id))
|
|
});
|
|
|
|
return router
|
|
} |