diff options
| author | Fuwn <[email protected]> | 2023-08-26 22:29:03 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-08-26 22:29:03 -0700 |
| commit | b89d0e7dada186e31be37e62a7a75efc2dbe9c99 (patch) | |
| tree | 8c9f6b5d7aa0f709c06d5eb45fbf763883b21c89 /src/routes/anilist | |
| download | due.moe-b89d0e7dada186e31be37e62a7a75efc2dbe9c99.tar.xz due.moe-b89d0e7dada186e31be37e62a7a75efc2dbe9c99.zip | |
feat: initial build
Diffstat (limited to 'src/routes/anilist')
| -rw-r--r-- | src/routes/anilist/increment/+server.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/routes/anilist/increment/+server.ts b/src/routes/anilist/increment/+server.ts new file mode 100644 index 00000000..4680236b --- /dev/null +++ b/src/routes/anilist/increment/+server.ts @@ -0,0 +1,27 @@ +export const GET = async ({ url, cookies }) => { + const userCookie = cookies.get('user'); + + if (!userCookie) { + return new Response('Unauthenticated', { status: 401 }); + } + + const user = JSON.parse(userCookie); + + return Response.json( + await ( + await fetch('https://graphql.anilist.co', { + method: 'POST', + headers: { + Authorization: `${user['token_type']} ${user['access_token']}`, + 'Content-Type': 'application/json', + Accept: 'application/json' + }, + body: JSON.stringify({ + query: `mutation { SaveMediaListEntry(mediaId: ${ + url.searchParams.get('id') || 'null' + }, progress: ${url.searchParams.get('progress') || 'null'}) { id } }` + }) + }) + ).json() + ); +}; |