mirror of
https://github.com/kremalicious/location.git
synced 2024-12-22 09:13:37 +01:00
typings
This commit is contained in:
parent
9b29dfb317
commit
0ea55f898e
@ -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
|
||||
|
25
api/index.ts
25
api/index.ts
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user