feat(build): add project configuration files and dependencies

Add IntelliJ IDEA project settings, TypeScript configuration, and pnpm lock file. Updated `package.json` with new dependencies and refactored API handler to TypeScript.
This commit is contained in:
2024-09-27 11:37:21 +02:00
parent 69d1186333
commit f87e388ddd
14 changed files with 4832 additions and 10 deletions

View File

@@ -1,8 +0,0 @@
export default async function handler(req, res) {
const { cityInput } = req.body;
const getWeatherData = await fetch(
`https://api.openweathermap.org/data/2.5/weather?q=${cityInput}&units=metric&appid=${process.env.OPENWEATHER_API_KEY}`
);
const data = await getWeatherData.json();
res.status(200).json(data);
}

11
pages/api/data.ts Normal file
View File

@@ -0,0 +1,11 @@
import _config from "../../configs/city.json"
import * as process from "node:process";
export default async function handler(req, res) {
const targetedCity = await fetch(process.env.CONFIG_URL as string) as unknown as typeof _config
const getWeatherData = await fetch(
`https://api.openweathermap.org/data/2.5/weather?q=${targetedCity.cityName}&units=metric&appid=${process.env.OPENWEATHER_API_KEY}`
);
const data = await getWeatherData.json();
res.status(200).json(data);
}