mirror of
https://github.com/pawelmalak/flame.git
synced 2026-02-28 09:23:12 +08:00
WeatherWidget temp unit. WeatherSettings update on change
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user