rhythia-api 176.0.0 → 177.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/addCollectionMap.ts +12 -0
- package/api/createCollection.ts +13 -6
- package/index.ts +1 -0
- package/package.json +1 -1
package/api/addCollectionMap.ts
CHANGED
|
@@ -37,6 +37,18 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
37
37
|
return NextResponse.json({ error: "Can't find user" });
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
let { data: queryCollectionRelation, error: collectionRelationError } =
|
|
41
|
+
await supabase
|
|
42
|
+
.from("collectionRelations")
|
|
43
|
+
.select("*")
|
|
44
|
+
.eq("collection", data.collection)
|
|
45
|
+
.eq("beatmapPage", data.beatmapPage)
|
|
46
|
+
.single();
|
|
47
|
+
|
|
48
|
+
if (queryCollectionRelation) {
|
|
49
|
+
return NextResponse.json({ error: "Map already in collection" });
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
let { data: queryCollectionData, error: collectionError } = await supabase
|
|
41
53
|
.from("beatmapCollections")
|
|
42
54
|
.select("*")
|
package/api/createCollection.ts
CHANGED
|
@@ -11,6 +11,7 @@ export const Schema = {
|
|
|
11
11
|
title: z.string(),
|
|
12
12
|
}),
|
|
13
13
|
output: z.object({
|
|
14
|
+
id: z.number(),
|
|
14
15
|
error: z.string().optional(),
|
|
15
16
|
}),
|
|
16
17
|
};
|
|
@@ -36,11 +37,17 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
36
37
|
return NextResponse.json({ error: "Can't find user" });
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
await supabase
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const inserted = await supabase
|
|
41
|
+
.from("beatmapCollections")
|
|
42
|
+
.insert({
|
|
43
|
+
title: data.title,
|
|
44
|
+
description: "",
|
|
45
|
+
owner: queryUserData.id,
|
|
46
|
+
})
|
|
47
|
+
.select("*")
|
|
48
|
+
.single();
|
|
44
49
|
|
|
45
|
-
return NextResponse.json({
|
|
50
|
+
return NextResponse.json({
|
|
51
|
+
id: inserted.data!.id,
|
|
52
|
+
});
|
|
46
53
|
}
|
package/index.ts
CHANGED