rhythia-api 122.0.0 → 124.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/approveMap.ts +1 -1
- package/api/getBeatmapPage.ts +4 -0
- package/api/nominateMap.ts +5 -1
- package/package.json +1 -1
- package/types/database.ts +3 -3
package/api/approveMap.ts
CHANGED
|
@@ -50,7 +50,7 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
50
50
|
return NextResponse.json({ error: "Bad map" });
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
if (mapData.nominations
|
|
53
|
+
if ((mapData.nominations as number[])!.length < 2) {
|
|
54
54
|
return NextResponse.json({
|
|
55
55
|
error: "Maps can get approved only if they have 2 approvals",
|
|
56
56
|
});
|
package/api/getBeatmapPage.ts
CHANGED
|
@@ -12,6 +12,8 @@ export const Schema = {
|
|
|
12
12
|
error: z.string().optional(),
|
|
13
13
|
beatmap: z
|
|
14
14
|
.object({
|
|
15
|
+
id: z.number().nullable().optional(),
|
|
16
|
+
nominations: z.array(z.number()).nullable().optional(),
|
|
15
17
|
playcount: z.number().nullable().optional(),
|
|
16
18
|
created_at: z.string().nullable().optional(),
|
|
17
19
|
difficulty: z.number().nullable().optional(),
|
|
@@ -86,6 +88,8 @@ export async function handler(
|
|
|
86
88
|
owner: beatmapPage.owner,
|
|
87
89
|
ownerUsername: beatmapPage.profiles?.username,
|
|
88
90
|
ownerAvatar: beatmapPage.profiles?.avatar_url,
|
|
91
|
+
id: beatmapPage.id,
|
|
92
|
+
nominations: beatmapPage.nominations as number[],
|
|
89
93
|
},
|
|
90
94
|
});
|
|
91
95
|
}
|
package/api/nominateMap.ts
CHANGED
|
@@ -50,9 +50,13 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
50
50
|
return NextResponse.json({ error: "Bad map" });
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
if ((mapData.nominations as number[]).includes(queryUserData.id)) {
|
|
54
|
+
return NextResponse.json({ error: "Already nominated" });
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
await supabase.from("beatmapPages").upsert({
|
|
54
58
|
id: data.mapId,
|
|
55
|
-
nominations: mapData.nominations!
|
|
59
|
+
nominations: [...(mapData.nominations! as number[]), queryUserData.id],
|
|
56
60
|
});
|
|
57
61
|
|
|
58
62
|
return NextResponse.json({});
|
package/package.json
CHANGED
package/types/database.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type Database = {
|
|
|
15
15
|
genre: string | null
|
|
16
16
|
id: number
|
|
17
17
|
latestBeatmapHash: string | null
|
|
18
|
-
nominations:
|
|
18
|
+
nominations: Json | null
|
|
19
19
|
owner: number | null
|
|
20
20
|
status: string | null
|
|
21
21
|
title: string | null
|
|
@@ -25,7 +25,7 @@ export type Database = {
|
|
|
25
25
|
genre?: string | null
|
|
26
26
|
id?: number
|
|
27
27
|
latestBeatmapHash?: string | null
|
|
28
|
-
nominations?:
|
|
28
|
+
nominations?: Json | null
|
|
29
29
|
owner?: number | null
|
|
30
30
|
status?: string | null
|
|
31
31
|
title?: string | null
|
|
@@ -35,7 +35,7 @@ export type Database = {
|
|
|
35
35
|
genre?: string | null
|
|
36
36
|
id?: number
|
|
37
37
|
latestBeatmapHash?: string | null
|
|
38
|
-
nominations?:
|
|
38
|
+
nominations?: Json | null
|
|
39
39
|
owner?: number | null
|
|
40
40
|
status?: string | null
|
|
41
41
|
title?: string | null
|