Setup something simple and straight-forward

This commit is contained in:
Taevas 2023-05-07 02:13:48 +02:00
parent 079f25673b
commit 5ec7cd193e
7 changed files with 85 additions and 4 deletions

View file

@ -0,0 +1,33 @@
import { Handler } from '@netlify/functions'
import { api } from "./shared/api"
const handler: Handler = async (event, context) => {
console.log(event)
let lastfm = await api<{
recenttracks: {
track: {
artist: {
"#text": string
},
image: {
size: string,
"#text": string
}[]
album: {
"#text": string
},
name: string,
"@attr"?: {
nowplaying?: string
}
}[]
}
}>
(`http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=TTTaevas&api_key=${process.env["API_LASTFM"]}&format=json&limit=1`)
return {
statusCode: 200,
body: JSON.stringify(lastfm.recenttracks.track[0])
}
}
export { handler }