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.
@@ -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("*")
@@ -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.from("beatmapCollections").insert({
40
- title: data.title,
41
- description: "",
42
- owner: queryUserData.id,
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
@@ -104,6 +104,7 @@ export const Schema = {
104
104
  title: z.string(),
105
105
  }),
106
106
  output: z.object({
107
+ id: z.number(),
107
108
  error: z.string().optional(),
108
109
  }),
109
110
  };*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "176.0.0",
3
+ "version": "177.0.0",
4
4
  "main": "index.ts",
5
5
  "author": "online-contributors",
6
6
  "scripts": {