rhythia-api 179.0.0 → 180.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/editCollection.ts +6 -0
- package/api/getCollection.ts +17 -1
- package/index.ts +4 -0
- package/package.json +1 -1
package/api/editCollection.ts
CHANGED
|
@@ -59,6 +59,12 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
if (data.description.length > 128) {
|
|
63
|
+
return NextResponse.json({
|
|
64
|
+
error: "Description too long",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
await supabase.from("beatmapCollections").upsert({
|
|
63
69
|
id: data.collection,
|
|
64
70
|
title: data.title,
|
package/api/getCollection.ts
CHANGED
|
@@ -12,6 +12,10 @@ export const Schema = {
|
|
|
12
12
|
collection: z.object({
|
|
13
13
|
title: z.string(),
|
|
14
14
|
description: z.string(),
|
|
15
|
+
owner: z.object({
|
|
16
|
+
id: z.number(),
|
|
17
|
+
username: z.string(),
|
|
18
|
+
}),
|
|
15
19
|
beatmaps: z.array(
|
|
16
20
|
z.object({
|
|
17
21
|
id: z.number(),
|
|
@@ -47,7 +51,15 @@ export async function POST(request: Request) {
|
|
|
47
51
|
export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
48
52
|
let { data: queryCollectionData, error: collectionError } = await supabase
|
|
49
53
|
.from("beatmapCollections")
|
|
50
|
-
.select(
|
|
54
|
+
.select(
|
|
55
|
+
`
|
|
56
|
+
*,
|
|
57
|
+
profiles!inner(
|
|
58
|
+
id,
|
|
59
|
+
username
|
|
60
|
+
)
|
|
61
|
+
`
|
|
62
|
+
)
|
|
51
63
|
.eq("id", data.collection)
|
|
52
64
|
.single();
|
|
53
65
|
|
|
@@ -104,6 +116,10 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
104
116
|
|
|
105
117
|
return NextResponse.json({
|
|
106
118
|
collection: {
|
|
119
|
+
owner: {
|
|
120
|
+
username: queryCollectionData.profiles.username,
|
|
121
|
+
id: queryCollectionData.profiles.id,
|
|
122
|
+
},
|
|
107
123
|
title: queryCollectionData.title,
|
|
108
124
|
description: queryCollectionData.description,
|
|
109
125
|
beatmaps: formattedBeatmaps,
|
package/index.ts
CHANGED