mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 01:06:28 +08:00
fix typescript errors and update dependencies
This commit is contained in:
@@ -10,6 +10,8 @@ interface UpdatesRequestBody {
|
||||
source?: string
|
||||
}
|
||||
|
||||
type NotificationDataEntry = [string, ...unknown[]]
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<UpdatesRequestBody>(event)
|
||||
const email = body.email?.trim().toLowerCase()
|
||||
@@ -38,7 +40,7 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
|
||||
if (result.created) {
|
||||
const dataEntries = [
|
||||
const dataEntries: NotificationDataEntry[] = [
|
||||
['Email', email],
|
||||
['Name', name || null],
|
||||
['Source', source],
|
||||
|
||||
@@ -13,6 +13,8 @@ interface WaitlistRequestBody {
|
||||
wantsProductUpdates?: boolean
|
||||
}
|
||||
|
||||
type NotificationDataEntry = [string, ...unknown[]]
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<WaitlistRequestBody>(event)
|
||||
const email = body.email?.trim().toLowerCase()
|
||||
@@ -57,7 +59,7 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
|
||||
if (!previouslyWantedUpdates && updateResult.created) {
|
||||
const dataEntries = [
|
||||
const dataEntries: NotificationDataEntry[] = [
|
||||
['Email', email],
|
||||
]
|
||||
if (name) {
|
||||
@@ -107,7 +109,7 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
const dataEntries = [
|
||||
const dataEntries: NotificationDataEntry[] = [
|
||||
['Email', email],
|
||||
]
|
||||
if (name) {
|
||||
@@ -132,4 +134,3 @@ export default defineEventHandler(async (event) => {
|
||||
joinedAt: entry.joinedAt,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
return await $fetch('https://data.vatsim.net/v3/vatsim-data.json')
|
||||
const fetcher = (globalThis as any).$fetch as (url: string, options?: Record<string, unknown>) => Promise<unknown>
|
||||
return await fetcher('https://data.vatsim.net/v3/vatsim-data.json')
|
||||
})
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import {defineEventHandler, getRouterParam} from 'h3'
|
||||
import { createError, defineEventHandler, getQuery } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const {cid} = getQuery(event)
|
||||
if (!cid) throw createError({statusCode: 400, statusMessage: 'cid required'})
|
||||
const query = getQuery(event)
|
||||
const rawCid = Array.isArray(query.cid) ? query.cid[0] : query.cid
|
||||
if (rawCid === undefined || rawCid === null) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'cid required' })
|
||||
}
|
||||
const cid = String(rawCid).trim()
|
||||
if (!cid) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'cid required' })
|
||||
}
|
||||
|
||||
const url = `https://api.vatsim.net/v2/members/${encodeURIComponent(cid)}/flightplans`
|
||||
return await $fetch(url, {method: 'GET'})
|
||||
const fetcher = (globalThis as any).$fetch as (target: string, options?: Record<string, unknown>) => Promise<unknown>
|
||||
return await fetcher(url, { method: 'GET' })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user