travopti/backend/routes/climate.js

50 lines
1.2 KiB
JavaScript

/**
* @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;
};