1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 03:29:37 +02:00

WeatherWidget temp unit. WeatherSettings update on change

This commit is contained in:
unknown 2021-06-07 12:17:10 +02:00
parent 08c769b630
commit d2e6ebae4f
8 changed files with 68 additions and 24 deletions

View file

@ -1,9 +1,10 @@
const asyncWrapper = require('../middleware/asyncWrapper');
const ErrorResponse = require('../utils/ErrorResponse');
const Weather = require('../models/Weather');
const getExternalWeather = require('../utils/getExternalWeather');
// @desc Get latest weather status
// @route POST /api/weather
// @route GET /api/weather
// @access Public
exports.getWeather = asyncWrapper(async (req, res, next) => {
const weather = await Weather.findAll({
@ -11,6 +12,18 @@ exports.getWeather = asyncWrapper(async (req, res, next) => {
limit: 1
});
res.status(200).json({
success: true,
data: weather
})
})
// @desc Update weather
// @route GET /api/weather/update
// @access Public
exports.updateWeather = asyncWrapper(async (req, res, next) => {
const weather = await getExternalWeather();
res.status(200).json({
success: true,
data: weather