|
|
|
@ -57,6 +57,7 @@ app.get(
|
|
|
|
await fetch(`https://api.ipbase.com/v2/info?ip=${ip}`)
|
|
|
|
await fetch(`https://api.ipbase.com/v2/info?ip=${ip}`)
|
|
|
|
).json()
|
|
|
|
).json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
const shortener = await db
|
|
|
|
const shortener = await db
|
|
|
|
.selectFrom('shortener')
|
|
|
|
.selectFrom('shortener')
|
|
|
|
.selectAll()
|
|
|
|
.selectAll()
|
|
|
|
@ -67,7 +68,8 @@ app.get(
|
|
|
|
const visitor_data = {
|
|
|
|
const visitor_data = {
|
|
|
|
shortener_id: shortener[0].id,
|
|
|
|
shortener_id: shortener[0].id,
|
|
|
|
country: geolocation.data.location.country.name as string,
|
|
|
|
country: geolocation.data.location.country.name as string,
|
|
|
|
country_code: geolocation.data.location.country.alpha2 as string,
|
|
|
|
country_code: geolocation.data.location.country
|
|
|
|
|
|
|
|
.alpha2 as string,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await db.insertInto('visitor').values(visitor_data).execute()
|
|
|
|
await db.insertInto('visitor').values(visitor_data).execute()
|
|
|
|
@ -78,6 +80,9 @@ app.get(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set.redirect = shortener[0].link
|
|
|
|
set.redirect = shortener[0].link
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
set.redirect = Bun.env.FALLBACK_URL
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|