Setup something simple and straight-forward
This commit is contained in:
parent
079f25673b
commit
5ec7cd193e
7 changed files with 85 additions and 4 deletions
33
netlify/functions/hello-world.ts
Normal file
33
netlify/functions/hello-world.ts
Normal 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 }
|
Loading…
Add table
Add a link
Reference in a new issue