-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add thunder alerts and local provider information
- Loading branch information
Showing
5 changed files
with
220 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
import React from 'react'; | ||
import { | ||
Html, Head, Main, NextScript, | ||
} from 'next/document'; | ||
|
||
export default function Document() { | ||
return ( | ||
<Html lang="fr-FR"> | ||
<Head> | ||
<meta name="theme-color" className="themecolor" content="#1c95ec" /> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" className="themecolor" content="#1c95ec" /> | ||
<meta name="description" content="Météo en temps réel, précise et fiable pour n'importe quelle ville du monde avec prévisions." /> | ||
<meta name="twitter:card" content="summary" /> | ||
<meta name="twitter:title" content="Météo – Léo SEGUIN" /> | ||
<meta name="twitter:description" content="Météo en temps réel, précise et fiable pour n'importe quelle ville du monde avec prévisions." /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:title" content="Météo – Léo SEGUIN" /> | ||
<meta property="og:description" content="Météo en temps réel, précise et fiable pour n'importe quelle ville du monde avec prévisions." /> | ||
<meta property="og:site_name" content="Météo – Léo SEGUIN" /> | ||
<meta property="og:url" content="https://meteo-leoseguin.vercel.app/" /> | ||
<meta property="og:locale" content="fr-FR" /> | ||
<link rel="canonical" href="https://meteo-leoseguin.vercel.app/" /> | ||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> | ||
<link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png" /> | ||
<link rel="manifest" href="/manifest.json" /> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
import React from 'react'; | ||
import { | ||
Html, Head, Main, NextScript, | ||
} from 'next/document'; | ||
|
||
export default function Document() { | ||
return ( | ||
<Html lang="fr-FR"> | ||
<Head> | ||
<meta name="theme-color" className="themecolor" content="#1c95ec" /> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" className="themecolor" content="#1c95ec" /> | ||
<meta name="description" content="Météo en temps réel, précise et fiable pour n'importe quelle ville du monde avec prévisions." /> | ||
<meta name="twitter:card" content="summary" /> | ||
<meta name="twitter:title" content="Météo – Léo SEGUIN" /> | ||
<meta name="twitter:description" content="Météo en temps réel, précise et fiable pour n'importe quelle ville du monde avec prévisions." /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:title" content="Météo – Léo SEGUIN" /> | ||
<meta property="og:description" content="Météo en temps réel, précise et fiable pour n'importe quelle ville du monde avec prévisions." /> | ||
<meta property="og:site_name" content="Météo – Léo SEGUIN" /> | ||
<meta property="og:url" content="https://meteo-leoseguin.vercel.app/" /> | ||
<meta property="og:locale" content="fr-FR" /> | ||
<link rel="canonical" href="https://meteo-leoseguin.vercel.app/" /> | ||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> | ||
<link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png" /> | ||
<link rel="manifest" href="/manifest.json" /> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
const fetchWeatherData = async (latitude, longitude) => { | ||
const key = process.env.API_KEY; | ||
const geocodingResponse = await fetch(`https://api.openweathermap.org/geo/1.0/reverse?lat=${latitude}&lon=${longitude}&limit=1&appid=${key}`); | ||
if (geocodingResponse.status === 404) { | ||
throw new Error('Geocoding API returned 404'); | ||
} | ||
const [geocodingData] = await geocodingResponse.json(); | ||
const [oneCallResponse, airPollutionResponse] = await Promise.all([ | ||
fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&appid=${key}&units=metric&exclude=minutely`), | ||
fetch(`https://api.openweathermap.org/data/2.5/air_pollution?lat=${latitude}&lon=${longitude}&appid=${key}`), | ||
]); | ||
if (oneCallResponse.status !== 200) { | ||
throw new Error('Unexpected error'); | ||
} | ||
const [oneCallData, airPollutionData] = await Promise.all([ | ||
oneCallResponse.json(), | ||
airPollutionResponse.json(), | ||
]); | ||
|
||
return { | ||
city: `${geocodingData.name}, ${geocodingData.country}`, | ||
oneCallData, | ||
airPollutionData, | ||
}; | ||
}; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method === 'POST') { | ||
const { latitude, longitude } = req.body; | ||
try { | ||
const { city, oneCallData, airPollutionData } = await fetchWeatherData(latitude, longitude); | ||
res.status(200).json({ city, oneCallData, airPollutionData }); | ||
} catch (error) { | ||
res.status(400).json({ error: error.message }); | ||
} | ||
} else { | ||
res.status(404).send(''); | ||
} | ||
} | ||
const fetchWeatherData = async (latitude, longitude) => { | ||
const key = process.env.API_KEY; | ||
const geocodingResponse = await fetch(`https://api.openweathermap.org/geo/1.0/reverse?lat=${latitude}&lon=${longitude}&limit=1&appid=${key}`); | ||
if (geocodingResponse.status === 404) { | ||
throw new Error('Geocoding API returned 404'); | ||
} | ||
const [geocodingData] = await geocodingResponse.json(); | ||
const [oneCallResponse, airPollutionResponse] = await Promise.all([ | ||
fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&appid=${key}&units=metric&exclude=minutely`), | ||
fetch(`https://api.openweathermap.org/data/2.5/air_pollution?lat=${latitude}&lon=${longitude}&appid=${key}`), | ||
]); | ||
if (oneCallResponse.status !== 200) { | ||
throw new Error('Unexpected error'); | ||
} | ||
const [oneCallData, airPollutionData] = await Promise.all([ | ||
oneCallResponse.json(), | ||
airPollutionResponse.json(), | ||
]); | ||
|
||
return { | ||
city: `${geocodingData.name}, ${geocodingData.country}`, | ||
oneCallData, | ||
airPollutionData, | ||
}; | ||
}; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method === 'POST') { | ||
const { latitude, longitude } = req.body; | ||
try { | ||
const { city, oneCallData, airPollutionData } = await fetchWeatherData(latitude, longitude); | ||
res.status(200).json({ city, oneCallData, airPollutionData }); | ||
} catch (error) { | ||
res.status(400).json({ error: error.message }); | ||
} | ||
} else { | ||
res.status(404).send(''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
const fetchWeatherData = async (ville) => { | ||
const key = process.env.API_KEY; | ||
const geocodingResponse = await fetch(`https://api.openweathermap.org/geo/1.0/direct?q=${ville}&limit=1&appid=${key}`); | ||
if (geocodingResponse.status === 404) { | ||
throw new Error('Geocoding API returned 404'); | ||
} | ||
const [geocodingData] = await geocodingResponse.json(); | ||
const latitude = geocodingData.lat; | ||
const longitude = geocodingData.lon; | ||
const [oneCallResponse, airPollutionResponse] = await Promise.all([ | ||
fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&appid=${key}&units=metric&exclude=minutely`), | ||
fetch(`https://api.openweathermap.org/data/2.5/air_pollution?lat=${latitude}&lon=${longitude}&appid=${key}`), | ||
]); | ||
if (oneCallResponse.status !== 200) { | ||
throw new Error('Unexpected error'); | ||
} | ||
const [oneCallData, airPollutionData] = await Promise.all([ | ||
oneCallResponse.json(), | ||
airPollutionResponse.json(), | ||
]); | ||
|
||
return { | ||
city: `${geocodingData.name}, ${geocodingData.country}`, | ||
oneCallData, | ||
airPollutionData, | ||
}; | ||
}; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method === 'POST') { | ||
const { ville } = req.body; | ||
try { | ||
const { city, oneCallData, airPollutionData } = await fetchWeatherData(ville); | ||
res.status(200).json({ city, oneCallData, airPollutionData }); | ||
} catch (error) { | ||
res.status(400).json({ error: error.message }); | ||
} | ||
} else { | ||
res.status(404).send(''); | ||
} | ||
} | ||
const fetchWeatherData = async (ville) => { | ||
const key = process.env.API_KEY; | ||
const geocodingResponse = await fetch(`https://api.openweathermap.org/geo/1.0/direct?q=${ville}&limit=1&appid=${key}`); | ||
if (geocodingResponse.status === 404) { | ||
throw new Error('Geocoding API returned 404'); | ||
} | ||
const [geocodingData] = await geocodingResponse.json(); | ||
const latitude = geocodingData.lat; | ||
const longitude = geocodingData.lon; | ||
const [oneCallResponse, airPollutionResponse] = await Promise.all([ | ||
fetch(`https://api.openweathermap.org/data/2.5/onecall?lat=${latitude}&lon=${longitude}&appid=${key}&units=metric&exclude=minutely`), | ||
fetch(`https://api.openweathermap.org/data/2.5/air_pollution?lat=${latitude}&lon=${longitude}&appid=${key}`), | ||
]); | ||
if (oneCallResponse.status !== 200) { | ||
throw new Error('Unexpected error'); | ||
} | ||
const [oneCallData, airPollutionData] = await Promise.all([ | ||
oneCallResponse.json(), | ||
airPollutionResponse.json(), | ||
]); | ||
|
||
return { | ||
city: `${geocodingData.name}, ${geocodingData.country}`, | ||
oneCallData, | ||
airPollutionData, | ||
}; | ||
}; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method === 'POST') { | ||
const { ville } = req.body; | ||
try { | ||
const { city, oneCallData, airPollutionData } = await fetchWeatherData(ville); | ||
res.status(200).json({ city, oneCallData, airPollutionData }); | ||
} catch (error) { | ||
res.status(400).json({ error: error.message }); | ||
} | ||
} else { | ||
res.status(404).send(''); | ||
} | ||
} |
Oops, something went wrong.
9972b57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
meteo – ./
meteo-leoseguin.vercel.app
meteo-git-main-leoseguin.vercel.app