This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/api/scrobble.js
Cory Dransfeldt d8cdb21b2e
chore: debug
2024-03-28 16:54:25 -07:00

37 lines
No EOL
924 B
JavaScript

import { getStore } from '@netlify/blobs'
export default async (request, context) => {
const ACCOUNT_ID_PLEX = Netlify.env.get("ACCOUNT_ID_PLEX");
const id = params.get('id')
const params = new URL(request['url']).searchParams
const data = await request.formData()
const payload = data['payload']
console.log(data)
console.log(payload)
if (!id) return new Response(JSON.stringify({
status: 'Bad request',
}),
{ headers: { "Content-Type": "application/json" } }
)
if (id !== ACCOUNT_ID_PLEX) return new Response(JSON.stringify({
status: 'Forbidden',
}),
{ headers: { "Content-Type": "application/json" } }
)
if (payload?.event === 'media.scrobble') {
console.log('scrobble')
}
return new Response(JSON.stringify({
status: 'success',
}),
{ headers: { "Content-Type": "application/json" } }
)
}
export const config = {
path: "/api/scrobble",
}