mirror of
https://github.com/ArthurDanjou/artchat.git
synced 2026-01-14 13:54:01 +01:00
refactor: update ESLint configuration and remove unused dependencies
- Replaced Nuxt ESLint configuration with Antfu's ESLint config. - Removed 'nuxt-visitors' module from Nuxt configuration. - Added linting scripts to package.json for easier code quality checks. - Introduced a new API endpoint for fetching weather data from OpenWeather. - Enhanced chat types with new enums and properties for better state management. - Added OpenWeather response types for improved type safety. - Updated social links in types/index.ts to include an email contact.
This commit is contained in:
26
server/api/weather/index.get.ts
Normal file
26
server/api/weather/index.get.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { OpenWeatherResponse } from '~~/types'
|
||||
|
||||
export default defineCachedEventHandler(async (event) => {
|
||||
const { openWeather } = useRuntimeConfig(event)
|
||||
const response = await $fetch<OpenWeatherResponse>(`https://api.openweathermap.org/data/2.5/weather`, {
|
||||
params: {
|
||||
q: 'Paris,FR',
|
||||
units: 'metric',
|
||||
lang: 'en',
|
||||
appid: openWeather.apiKey,
|
||||
},
|
||||
})
|
||||
const weather = {
|
||||
location: response.name,
|
||||
temperature: Math.round(response.main.temp),
|
||||
temp_min: Math.round(response.main.temp_min),
|
||||
temp_max: Math.round(response.main.temp_max),
|
||||
humidity: response.main.humidity,
|
||||
wind: response.wind.speed,
|
||||
description: response.weather[0].description,
|
||||
}
|
||||
|
||||
return weather
|
||||
}, {
|
||||
maxAge: 12 * 60 * 60, // 12 hours
|
||||
})
|
||||
Reference in New Issue
Block a user