This commit is contained in:
Matthias Kretschmann 2021-12-03 00:40:34 +00:00
parent 9b29dfb317
commit 0ea55f898e
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 24 additions and 3 deletions

View File

@ -10,7 +10,7 @@
## 🏄 Usage
Location is currently fetched from my (private) nomadlist.com profile, making sure the API key is hidden from any browser, and only the relevant location data is exposed instead of the whole profile data.
Location is currently fetched from my (private) nomadlist.com profile, making sure the API key is hidden from any browser, and only the relevant location data is exposed instead of the whole profile data response.
```text
https://location.kremalicious.com

View File

@ -1,11 +1,32 @@
import { VercelRequest, VercelResponse } from '@vercel/node'
import axios, { AxiosResponse, Method } from 'axios'
import axios, { AxiosResponse } from 'axios'
interface NomadListLocation {
city: string
country: string
country_code: string
latitude: number
longitude: number
epoch_start: number
epoch_end: number
date_start: string
date_end: string
place_photo: string
}
interface NomadListLocationResponse {
location: {
now: NomadListLocation
previous: NomadListLocation
next: NomadListLocation
}
}
export default async (req: VercelRequest, res: VercelResponse) => {
if (!process.env.NOMADLIST_PROFILE) return
try {
const response = await axios(
const response: AxiosResponse<NomadListLocationResponse> = await axios(
`https://nomadlist.com/@${process.env.NOMADLIST_PROFILE}.json?key=${process.env.NOMADLIST_KEY}`
)
if (!response?.data) return