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:
parent
08c769b630
commit
d2e6ebae4f
8 changed files with 68 additions and 24 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue