Initial commit: Vuelato - buscador de vuelos
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Nuxt 4 + Supabase + Flightics API. Incluye búsqueda de vuelos, inspiraciones, watchlist, tracking de precios y mapa interactivo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
server/api/sync/airlines.post.ts
Normal file
25
server/api/sync/airlines.post.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { serverSupabaseServiceRole } from '#supabase/server'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const supabase = serverSupabaseServiceRole(event)
|
||||
|
||||
const airlines = await getAirlinesFromWikidata()
|
||||
|
||||
const rows = airlines.map(a => ({
|
||||
iata: a.iata,
|
||||
icao: a.icao,
|
||||
name: a.name,
|
||||
logo_url: a.logoUrl,
|
||||
website: a.website,
|
||||
updated_at: new Date().toISOString()
|
||||
}))
|
||||
|
||||
if (rows.length > 0) {
|
||||
const { error } = await supabase
|
||||
.from('airlines')
|
||||
.upsert(rows as never, { onConflict: 'iata' })
|
||||
if (error) throw createError({ statusCode: 500, message: error.message })
|
||||
}
|
||||
|
||||
return { count: rows.length }
|
||||
})
|
||||
Reference in New Issue
Block a user