aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/preferences
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-03 09:04:44 -0800
committerFuwn <[email protected]>2026-03-03 09:08:43 -0800
commit6a44eac70c41bb1343a20ddf3ce775e416214d75 (patch)
treec5128228834222a1a6f0cc93869215a806bd9a0a /src/routes/api/preferences
parentrefactor(effect): migrate api auth cookie decoding (diff)
downloaddue.moe-6a44eac70c41bb1343a20ddf3ce775e416214d75.tar.xz
due.moe-6a44eac70c41bb1343a20ddf3ce775e416214d75.zip
refactor(effect): add request body schema decoders to api routes
Diffstat (limited to 'src/routes/api/preferences')
-rw-r--r--src/routes/api/preferences/+server.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/routes/api/preferences/+server.ts b/src/routes/api/preferences/+server.ts
index 0a30274b..0f62fb76 100644
--- a/src/routes/api/preferences/+server.ts
+++ b/src/routes/api/preferences/+server.ts
@@ -1,5 +1,6 @@
import { userIdentity } from "$lib/Data/AniList/identity";
import { decodeAuthCookieOrThrow } from "$lib/Effect/authCookie";
+import { decodeRequestJsonOrThrow } from "$lib/Effect/requestBody";
import {
getUserPreferences,
toggleHideMissingBadges,
@@ -9,6 +10,7 @@ import {
togglePinnedBadgeWallCategory,
setPinnedBadgeWallCategories,
} from "$lib/Database/SB/User/preferences";
+import { Schema } from "effect";
const unauthorised = new Response("Unauthorised", { status: 401 });
@@ -68,7 +70,12 @@ export const PUT = async ({ url, cookies, request }) => {
if (url.searchParams.get("setCategories") !== null)
return Response.json(
- await setPinnedBadgeWallCategories(userId, await request.json()),
+ await setPinnedBadgeWallCategories(userId, [
+ ...(await decodeRequestJsonOrThrow(
+ request,
+ Schema.Array(Schema.String),
+ )),
+ ]),
{
headers: {
"Access-Control-Allow-Origin": "https://due.moe",