parent
e779a9bee9
commit
8cdacbb9e5
1 changed files with 12 additions and 35 deletions
|
@ -46,6 +46,13 @@ export default async () => {
|
|||
const TV_KEY = Netlify.env.get('API_KEY_TRAKT')
|
||||
// eslint-disable-next-line no-undef
|
||||
const MUSIC_KEY = Netlify.env.get('API_KEY_LASTFM')
|
||||
const headers = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
|
||||
},
|
||||
}
|
||||
|
||||
const traktRes = await fetch('https://api.trakt.tv/users/cdransf/watching', {
|
||||
headers: {
|
||||
|
@ -66,13 +73,7 @@ export default async () => {
|
|||
{
|
||||
content: `📺 <a href="https://trakt.tv/shows/${traktRes['show']['ids']['slug']}">${traktRes['show']['title']}</a> • <a href="https://trakt.tv/shows/${traktRes['show']['ids']['slug']}/seasons/${traktRes['episode']['season']}/episodes/${traktRes['episode']['number']}">${traktRes['episode']['title']}</a>`,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
|
||||
},
|
||||
}
|
||||
headers
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -81,13 +82,7 @@ export default async () => {
|
|||
{
|
||||
content: `🎥 <a href="https://trakt.tv/movies/${traktRes['movie']['ids']['slug']}">${traktRes['movie']['title']}</a>`,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
|
||||
},
|
||||
}
|
||||
headers
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -131,22 +126,10 @@ export default async () => {
|
|||
|
||||
if (isCorrectDate) {
|
||||
if (nowHour === startHour && nowMinutes >= startMinutes && nowHour < endHour)
|
||||
return Response.json(res, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
|
||||
},
|
||||
})
|
||||
return Response.json(res, headers)
|
||||
if (nowHour > startHour && nowHour < endHour) return Response.json(res)
|
||||
if (nowHour > startHour && nowMinutes <= endMinutes && nowHour == endHour)
|
||||
return Response.json(res, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
|
||||
},
|
||||
})
|
||||
return Response.json(res, headers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,13 +177,7 @@ export default async () => {
|
|||
track['name']
|
||||
}</a> by <a href="${artistUrl}">${track['artist']['#text']}</a>`,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Cache-Control': 'public, max-age=0, must-revalidate',
|
||||
'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
|
||||
},
|
||||
}
|
||||
headers
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue