-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee5f3f2
commit 8f588da
Showing
272 changed files
with
10,742 additions
and
472 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": ["prettier-plugin-tailwindcss"], | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"semi": false | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const getAirPollutionData = async ({ | ||
lat, | ||
lon, | ||
}: { | ||
lat: string | ||
lon: string | ||
}) => { | ||
const data = await fetch( | ||
`http://localhost:3000/api/weather/air_pollution?lat=${lat}&lon=${lon}&appid=${process.env.NEXT_PUBLIC_OPEN_WEATHER_API_KEY}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
return data.json() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const getHourlyData = async ({ | ||
lat, | ||
lon, | ||
}: { | ||
lat: string | ||
lon: string | ||
}) => { | ||
const data = await fetch( | ||
`http://localhost:3000/api/weather/hourly?lat=${lat}&lon=${lon}&appid=${process.env.NEXT_PUBLIC_OPEN_WEATHER_API_KEY}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
return data.json() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const getTenDayForecast = async ({ | ||
lat, | ||
lon, | ||
}: { | ||
lat: string | ||
lon: string | ||
}) => { | ||
const data = await fetch( | ||
`http://localhost:3000/api/weather/daily_forecast?lat=${lat}&lon=${lon}&appid=${process.env.NEXT_PUBLIC_OPEN_WEATHER_API_KEY}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
return data.json() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const getUVData = async ({ lat, lon }: { lat: string; lon: string }) => { | ||
const data = await fetch( | ||
`http://localhost:3000/api/weather/uv_index?lat=${lat}&lon=${lon}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
return data.json() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url) | ||
const lat = searchParams.get("lat") | ||
const lon = searchParams.get("lon") | ||
const appid = searchParams.get("appid") | ||
|
||
if (!appid) { | ||
return Response.json( | ||
{ message: "OpenWeather API key not found in environment variables" }, | ||
{ status: 401 } | ||
) | ||
} | ||
if (!lat || !lon) { | ||
return Response.json({ message: "Missing lat param" }, { status: 400 }) | ||
} | ||
|
||
const res = await fetch( | ||
`http://api.openweathermap.org/data/2.5/air_pollution?lat=${lat}&lon=${lon}&units=metric&appid=${appid}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
if (!res.ok) { | ||
throw new Error("Failed to fetch data") | ||
} | ||
|
||
const data = await res.json() | ||
|
||
return Response.json(data) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url) | ||
const lat = searchParams.get("lat") | ||
const lon = searchParams.get("lon") | ||
const appid = searchParams.get("appid") | ||
const NUMBER_OF_DAYS = 10 | ||
|
||
if (!appid) { | ||
return Response.json( | ||
{ message: "OpenWeather API key not found in environment variables" }, | ||
{ status: 401 } | ||
) | ||
} | ||
|
||
if (!lat || !lon) { | ||
return Response.json({ message: "Missing lat param" }, { status: 400 }) | ||
} | ||
|
||
const res = await fetch( | ||
`http://api.openweathermap.org/data/2.5/forecast/daily?lat=${lat}&lon=${lon}&cnt=${NUMBER_OF_DAYS}&units=metric&appid=${appid}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
if (!res.ok) { | ||
throw new Error("Failed to fetch data") | ||
} | ||
|
||
const data = await res.json() | ||
|
||
return Response.json(data) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url) | ||
const lat = searchParams.get("lat") | ||
const lon = searchParams.get("lon") | ||
const appid = searchParams.get("appid") | ||
const HOURS = 23 | ||
|
||
if (!appid) { | ||
return Response.json( | ||
{ message: "OpenWeather API key not found in environment variables" }, | ||
{ status: 401 } | ||
) | ||
} | ||
if (!lat || !lon) { | ||
return Response.json({ message: "Missing parameters" }, { status: 400 }) | ||
} | ||
|
||
const res = await fetch( | ||
`https://pro.openweathermap.org/data/2.5/forecast/hourly?lat=${lat}&lon=${lon}&cnt=${HOURS}&units=metric&appid=${appid}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
if (!res.ok) { | ||
throw new Error("Failed to fetch data") | ||
} | ||
|
||
const data = await res.json() | ||
|
||
return Response.json(data) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url) | ||
const lat = searchParams.get("lat") | ||
const lon = searchParams.get("lon") | ||
const appid = searchParams.get("appid") | ||
|
||
if (!appid) { | ||
return Response.json( | ||
{ message: "OpenWeather API key not found in environment variables" }, | ||
{ status: 401 } | ||
) | ||
} | ||
if (!lat || !lon) { | ||
return Response.json({ message: "Missing parameters" }, { status: 400 }) | ||
} | ||
|
||
const res = await fetch( | ||
`https://pro.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=metric&appid=${appid}`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
if (!res.ok) { | ||
throw new Error("Failed to fetch data") | ||
} | ||
|
||
const data = await res.json() | ||
|
||
return Response.json(data) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url) | ||
const lat = searchParams.get("lat") | ||
const lon = searchParams.get("lon") | ||
|
||
if (!lat || !lon) { | ||
return Response.json({ message: "Missing parameters" }, { status: 400 }) | ||
} | ||
|
||
const res = await fetch( | ||
`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&daily=uv_index_max,uv_index_clear_sky_max&timezone=auto&forecast_days=1`, | ||
{ | ||
next: { revalidate: 900 }, | ||
} | ||
) | ||
|
||
if (!res.ok) { | ||
throw new Error("Failed to fetch data") | ||
} | ||
|
||
const data = await res.json() | ||
|
||
return Response.json(data) | ||
} |
Binary file not shown.
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
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,22 +1,44 @@ | ||
import type { Metadata } from 'next' | ||
import { Inter } from 'next/font/google' | ||
import './globals.css' | ||
import { Inter } from "next/font/google" | ||
import "./globals.css" | ||
import Script from "next/script" | ||
import { NextThemesProvider } from "@/components/providers/NextThemesProvider" | ||
import { CodeIcon, HeartIcon } from "@radix-ui/react-icons" | ||
import Navigation from "@/components/Navigation" | ||
|
||
const inter = Inter({ subsets: ['latin'] }) | ||
|
||
export const metadata: Metadata = { | ||
title: 'Create Next App', | ||
description: 'Generated by create next app', | ||
} | ||
const inter = Inter({ subsets: ["latin"] }) | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}>{children}</body> | ||
<html lang="en" suppressHydrationWarning> | ||
<body | ||
className={`${inter.className}, container mx-auto flex min-h-screen flex-col antialiased selection:bg-black selection:text-white dark:bg-black dark:selection:bg-white dark:selection:text-black`} | ||
> | ||
<NextThemesProvider | ||
attribute="class" | ||
defaultTheme="system" | ||
enableSystem | ||
disableTransitionOnChange | ||
> | ||
<Navigation /> | ||
<main className="flex-grow">{children}</main> | ||
<footer className="group py-4"> | ||
<div className="flex items-center justify-center gap-1 text-neutral-400 dark:text-neutral-600"> | ||
<CodeIcon className="h-5 w-5" /> | ||
<span>with</span> | ||
<HeartIcon className="h-4 w-4 group-hover:text-red-500" /> | ||
<span>in Denmark</span> | ||
</div> | ||
</footer> | ||
</NextThemesProvider> | ||
<Script | ||
strategy={"beforeInteractive"} | ||
src={`https://maps.googleapis.com/maps/api/js?key=${process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY}&libraries=places&callback=Function.prototype`} | ||
/> | ||
</body> | ||
</html> | ||
) | ||
} |
Oops, something went wrong.