rhythia-api 182.0.0 → 183.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/.prettierrc.json +6 -6
- package/api/addCollectionMap.ts +82 -82
- package/api/approveMap.ts +78 -78
- package/api/chartPublicStats.ts +32 -32
- package/api/createBeatmap.ts +168 -156
- package/api/createBeatmapPage.ts +64 -64
- package/api/createClan.ts +81 -81
- package/api/createCollection.ts +58 -58
- package/api/deleteBeatmapPage.ts +77 -72
- package/api/deleteCollection.ts +59 -59
- package/api/deleteCollectionMap.ts +71 -71
- package/api/editAboutMe.ts +91 -91
- package/api/editClan.ts +90 -90
- package/api/editCollection.ts +77 -77
- package/api/editProfile.ts +123 -123
- package/api/getAvatarUploadUrl.ts +85 -85
- package/api/getBadgedUsers.ts +56 -56
- package/api/getBeatmapComments.ts +57 -57
- package/api/getBeatmapPage.ts +106 -106
- package/api/getBeatmapPageById.ts +99 -99
- package/api/getBeatmapStarRating.ts +53 -53
- package/api/getBeatmaps.ts +159 -159
- package/api/getClan.ts +77 -77
- package/api/getCollection.ts +130 -130
- package/api/getCollections.ts +128 -126
- package/api/getLeaderboard.ts +136 -136
- package/api/getMapUploadUrl.ts +93 -93
- package/api/getPassToken.ts +55 -55
- package/api/getProfile.ts +146 -146
- package/api/getPublicStats.ts +180 -180
- package/api/getRawStarRating.ts +57 -57
- package/api/getScore.ts +85 -85
- package/api/getTimestamp.ts +23 -23
- package/api/getUserScores.ts +175 -175
- package/api/nominateMap.ts +82 -69
- package/api/postBeatmapComment.ts +59 -59
- package/api/rankMapsArchive.ts +64 -64
- package/api/searchUsers.ts +56 -56
- package/api/setPasskey.ts +59 -59
- package/api/submitScore.ts +433 -433
- package/api/updateBeatmapPage.ts +229 -229
- package/handleApi.ts +20 -20
- package/index.html +2 -2
- package/index.ts +865 -864
- package/package.json +2 -2
- package/types/database.ts +39 -0
- package/utils/getUserBySession.ts +48 -48
- package/utils/requestUtils.ts +87 -87
- package/utils/security.ts +20 -20
- package/utils/star-calc/index.ts +72 -72
- package/utils/star-calc/osuUtils.ts +53 -53
- package/utils/star-calc/sspmParser.ts +398 -398
- package/utils/star-calc/sspmv1Parser.ts +165 -165
- package/utils/supabase.ts +13 -13
- package/utils/test +4 -4
- package/utils/validateToken.ts +7 -7
- package/vercel.json +12 -12
- package/package-lock.json +0 -8913
package/api/getBeatmapPage.ts
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { NextResponse } from "next/server";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
-
import { supabase } from "../utils/supabase";
|
|
5
|
-
|
|
6
|
-
export const Schema = {
|
|
7
|
-
input: z.strictObject({
|
|
8
|
-
session: z.string(),
|
|
9
|
-
id: z.number(),
|
|
10
|
-
}),
|
|
11
|
-
output: z.object({
|
|
12
|
-
error: z.string().optional(),
|
|
13
|
-
beatmap: z
|
|
14
|
-
.object({
|
|
15
|
-
id: z.number().nullable().optional(),
|
|
16
|
-
nominations: z.array(z.number()).nullable().optional(),
|
|
17
|
-
playcount: z.number().nullable().optional(),
|
|
18
|
-
created_at: z.string().nullable().optional(),
|
|
19
|
-
updated_at: z.number().nullable().optional(),
|
|
20
|
-
difficulty: z.number().nullable().optional(),
|
|
21
|
-
noteCount: z.number().nullable().optional(),
|
|
22
|
-
length: z.number().nullable().optional(),
|
|
23
|
-
title: z.string().nullable().optional(),
|
|
24
|
-
ranked: z.boolean().nullable().optional(),
|
|
25
|
-
beatmapFile: z.string().nullable().optional(),
|
|
26
|
-
image: z.string().nullable().optional(),
|
|
27
|
-
imageLarge: z.string().nullable().optional(),
|
|
28
|
-
starRating: z.number().nullable().optional(),
|
|
29
|
-
owner: z.number().nullable().optional(),
|
|
30
|
-
ownerUsername: z.string().nullable().optional(),
|
|
31
|
-
ownerAvatar: z.string().nullable().optional(),
|
|
32
|
-
status: z.string().nullable().optional(),
|
|
33
|
-
description: z.string().nullable().optional(),
|
|
34
|
-
tags: z.string().nullable().optional(),
|
|
35
|
-
})
|
|
36
|
-
.optional(),
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export async function POST(request: Request): Promise<NextResponse> {
|
|
41
|
-
return protectedApi({
|
|
42
|
-
request,
|
|
43
|
-
schema: Schema,
|
|
44
|
-
authorization: () => {},
|
|
45
|
-
activity: handler,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export async function handler(
|
|
50
|
-
data: (typeof Schema)["input"]["_type"],
|
|
51
|
-
req: Request
|
|
52
|
-
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
53
|
-
let { data: beatmapPage, error: errorlast } = await supabase
|
|
54
|
-
.from("beatmapPages")
|
|
55
|
-
.select(
|
|
56
|
-
`
|
|
57
|
-
*,
|
|
58
|
-
beatmaps (
|
|
59
|
-
created_at,
|
|
60
|
-
playcount,
|
|
61
|
-
length,
|
|
62
|
-
ranked,
|
|
63
|
-
beatmapFile,
|
|
64
|
-
image,
|
|
65
|
-
imageLarge,
|
|
66
|
-
starRating,
|
|
67
|
-
difficulty,
|
|
68
|
-
noteCount,
|
|
69
|
-
title
|
|
70
|
-
),
|
|
71
|
-
profiles (
|
|
72
|
-
username,
|
|
73
|
-
avatar_url
|
|
74
|
-
)
|
|
75
|
-
`
|
|
76
|
-
)
|
|
77
|
-
.eq("id", data.id)
|
|
78
|
-
.single();
|
|
79
|
-
|
|
80
|
-
if (!beatmapPage) return NextResponse.json({});
|
|
81
|
-
|
|
82
|
-
return NextResponse.json({
|
|
83
|
-
beatmap: {
|
|
84
|
-
playcount: beatmapPage.beatmaps?.playcount,
|
|
85
|
-
created_at: beatmapPage.created_at,
|
|
86
|
-
updated_at: beatmapPage.updated_at,
|
|
87
|
-
difficulty: beatmapPage.beatmaps?.difficulty,
|
|
88
|
-
noteCount: beatmapPage.beatmaps?.noteCount,
|
|
89
|
-
length: beatmapPage.beatmaps?.length,
|
|
90
|
-
title: beatmapPage.beatmaps?.title,
|
|
91
|
-
ranked: beatmapPage.beatmaps?.ranked,
|
|
92
|
-
beatmapFile: beatmapPage.beatmaps?.beatmapFile,
|
|
93
|
-
image: beatmapPage.beatmaps?.image,
|
|
94
|
-
imageLarge: beatmapPage.beatmaps?.imageLarge,
|
|
95
|
-
starRating: beatmapPage.beatmaps?.starRating,
|
|
96
|
-
owner: beatmapPage.owner,
|
|
97
|
-
ownerUsername: beatmapPage.profiles?.username,
|
|
98
|
-
ownerAvatar: beatmapPage.profiles?.avatar_url,
|
|
99
|
-
id: beatmapPage.id,
|
|
100
|
-
status: beatmapPage.status,
|
|
101
|
-
nominations: beatmapPage.nominations as number[],
|
|
102
|
-
description: beatmapPage.description,
|
|
103
|
-
tags: beatmapPage.tags,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
}
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
+
import { supabase } from "../utils/supabase";
|
|
5
|
+
|
|
6
|
+
export const Schema = {
|
|
7
|
+
input: z.strictObject({
|
|
8
|
+
session: z.string(),
|
|
9
|
+
id: z.number(),
|
|
10
|
+
}),
|
|
11
|
+
output: z.object({
|
|
12
|
+
error: z.string().optional(),
|
|
13
|
+
beatmap: z
|
|
14
|
+
.object({
|
|
15
|
+
id: z.number().nullable().optional(),
|
|
16
|
+
nominations: z.array(z.number()).nullable().optional(),
|
|
17
|
+
playcount: z.number().nullable().optional(),
|
|
18
|
+
created_at: z.string().nullable().optional(),
|
|
19
|
+
updated_at: z.number().nullable().optional(),
|
|
20
|
+
difficulty: z.number().nullable().optional(),
|
|
21
|
+
noteCount: z.number().nullable().optional(),
|
|
22
|
+
length: z.number().nullable().optional(),
|
|
23
|
+
title: z.string().nullable().optional(),
|
|
24
|
+
ranked: z.boolean().nullable().optional(),
|
|
25
|
+
beatmapFile: z.string().nullable().optional(),
|
|
26
|
+
image: z.string().nullable().optional(),
|
|
27
|
+
imageLarge: z.string().nullable().optional(),
|
|
28
|
+
starRating: z.number().nullable().optional(),
|
|
29
|
+
owner: z.number().nullable().optional(),
|
|
30
|
+
ownerUsername: z.string().nullable().optional(),
|
|
31
|
+
ownerAvatar: z.string().nullable().optional(),
|
|
32
|
+
status: z.string().nullable().optional(),
|
|
33
|
+
description: z.string().nullable().optional(),
|
|
34
|
+
tags: z.string().nullable().optional(),
|
|
35
|
+
})
|
|
36
|
+
.optional(),
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export async function POST(request: Request): Promise<NextResponse> {
|
|
41
|
+
return protectedApi({
|
|
42
|
+
request,
|
|
43
|
+
schema: Schema,
|
|
44
|
+
authorization: () => {},
|
|
45
|
+
activity: handler,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function handler(
|
|
50
|
+
data: (typeof Schema)["input"]["_type"],
|
|
51
|
+
req: Request
|
|
52
|
+
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
53
|
+
let { data: beatmapPage, error: errorlast } = await supabase
|
|
54
|
+
.from("beatmapPages")
|
|
55
|
+
.select(
|
|
56
|
+
`
|
|
57
|
+
*,
|
|
58
|
+
beatmaps (
|
|
59
|
+
created_at,
|
|
60
|
+
playcount,
|
|
61
|
+
length,
|
|
62
|
+
ranked,
|
|
63
|
+
beatmapFile,
|
|
64
|
+
image,
|
|
65
|
+
imageLarge,
|
|
66
|
+
starRating,
|
|
67
|
+
difficulty,
|
|
68
|
+
noteCount,
|
|
69
|
+
title
|
|
70
|
+
),
|
|
71
|
+
profiles (
|
|
72
|
+
username,
|
|
73
|
+
avatar_url
|
|
74
|
+
)
|
|
75
|
+
`
|
|
76
|
+
)
|
|
77
|
+
.eq("id", data.id)
|
|
78
|
+
.single();
|
|
79
|
+
|
|
80
|
+
if (!beatmapPage) return NextResponse.json({});
|
|
81
|
+
|
|
82
|
+
return NextResponse.json({
|
|
83
|
+
beatmap: {
|
|
84
|
+
playcount: beatmapPage.beatmaps?.playcount,
|
|
85
|
+
created_at: beatmapPage.created_at,
|
|
86
|
+
updated_at: beatmapPage.updated_at,
|
|
87
|
+
difficulty: beatmapPage.beatmaps?.difficulty,
|
|
88
|
+
noteCount: beatmapPage.beatmaps?.noteCount,
|
|
89
|
+
length: beatmapPage.beatmaps?.length,
|
|
90
|
+
title: beatmapPage.beatmaps?.title,
|
|
91
|
+
ranked: beatmapPage.beatmaps?.ranked,
|
|
92
|
+
beatmapFile: beatmapPage.beatmaps?.beatmapFile,
|
|
93
|
+
image: beatmapPage.beatmaps?.image,
|
|
94
|
+
imageLarge: beatmapPage.beatmaps?.imageLarge,
|
|
95
|
+
starRating: beatmapPage.beatmaps?.starRating,
|
|
96
|
+
owner: beatmapPage.owner,
|
|
97
|
+
ownerUsername: beatmapPage.profiles?.username,
|
|
98
|
+
ownerAvatar: beatmapPage.profiles?.avatar_url,
|
|
99
|
+
id: beatmapPage.id,
|
|
100
|
+
status: beatmapPage.status,
|
|
101
|
+
nominations: beatmapPage.nominations as number[],
|
|
102
|
+
description: beatmapPage.description,
|
|
103
|
+
tags: beatmapPage.tags,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { NextResponse } from "next/server";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
-
import { supabase } from "../utils/supabase";
|
|
5
|
-
|
|
6
|
-
export const Schema = {
|
|
7
|
-
input: z.strictObject({
|
|
8
|
-
session: z.string(),
|
|
9
|
-
mapId: z.string(),
|
|
10
|
-
}),
|
|
11
|
-
output: z.object({
|
|
12
|
-
error: z.string().optional(),
|
|
13
|
-
beatmap: z
|
|
14
|
-
.object({
|
|
15
|
-
id: z.number().nullable().optional(),
|
|
16
|
-
nominations: z.array(z.number()).nullable().optional(),
|
|
17
|
-
playcount: z.number().nullable().optional(),
|
|
18
|
-
created_at: z.string().nullable().optional(),
|
|
19
|
-
updated_at: z.number().nullable().optional(),
|
|
20
|
-
difficulty: z.number().nullable().optional(),
|
|
21
|
-
noteCount: z.number().nullable().optional(),
|
|
22
|
-
length: z.number().nullable().optional(),
|
|
23
|
-
title: z.string().nullable().optional(),
|
|
24
|
-
ranked: z.boolean().nullable().optional(),
|
|
25
|
-
beatmapFile: z.string().nullable().optional(),
|
|
26
|
-
image: z.string().nullable().optional(),
|
|
27
|
-
starRating: z.number().nullable().optional(),
|
|
28
|
-
owner: z.number().nullable().optional(),
|
|
29
|
-
ownerUsername: z.string().nullable().optional(),
|
|
30
|
-
ownerAvatar: z.string().nullable().optional(),
|
|
31
|
-
status: z.string().nullable().optional(),
|
|
32
|
-
})
|
|
33
|
-
.optional(),
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export async function POST(request: Request): Promise<NextResponse> {
|
|
38
|
-
return protectedApi({
|
|
39
|
-
request,
|
|
40
|
-
schema: Schema,
|
|
41
|
-
authorization: () => {},
|
|
42
|
-
activity: handler,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function handler(
|
|
47
|
-
data: (typeof Schema)["input"]["_type"],
|
|
48
|
-
req: Request
|
|
49
|
-
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
50
|
-
let { data: beatmapPage, error: errorlast } = await supabase
|
|
51
|
-
.from("beatmapPages")
|
|
52
|
-
.select(
|
|
53
|
-
`
|
|
54
|
-
*,
|
|
55
|
-
beatmaps (
|
|
56
|
-
created_at,
|
|
57
|
-
playcount,
|
|
58
|
-
length,
|
|
59
|
-
ranked,
|
|
60
|
-
beatmapFile,
|
|
61
|
-
image,
|
|
62
|
-
starRating,
|
|
63
|
-
difficulty,
|
|
64
|
-
noteCount,
|
|
65
|
-
title
|
|
66
|
-
),
|
|
67
|
-
profiles (
|
|
68
|
-
username,
|
|
69
|
-
avatar_url
|
|
70
|
-
)
|
|
71
|
-
`
|
|
72
|
-
)
|
|
73
|
-
.eq("latestBeatmapHash", data.mapId)
|
|
74
|
-
.single();
|
|
75
|
-
|
|
76
|
-
if (!beatmapPage) return NextResponse.json({});
|
|
77
|
-
|
|
78
|
-
return NextResponse.json({
|
|
79
|
-
beatmap: {
|
|
80
|
-
playcount: beatmapPage.beatmaps?.playcount,
|
|
81
|
-
created_at: beatmapPage.created_at,
|
|
82
|
-
updated_at: beatmapPage.updated_at,
|
|
83
|
-
difficulty: beatmapPage.beatmaps?.difficulty,
|
|
84
|
-
noteCount: beatmapPage.beatmaps?.noteCount,
|
|
85
|
-
length: beatmapPage.beatmaps?.length,
|
|
86
|
-
title: beatmapPage.beatmaps?.title,
|
|
87
|
-
ranked: beatmapPage.beatmaps?.ranked,
|
|
88
|
-
beatmapFile: beatmapPage.beatmaps?.beatmapFile,
|
|
89
|
-
image: beatmapPage.beatmaps?.image,
|
|
90
|
-
starRating: beatmapPage.beatmaps?.starRating,
|
|
91
|
-
owner: beatmapPage.owner,
|
|
92
|
-
ownerUsername: beatmapPage.profiles?.username,
|
|
93
|
-
ownerAvatar: beatmapPage.profiles?.avatar_url,
|
|
94
|
-
id: beatmapPage.id,
|
|
95
|
-
status: beatmapPage.status,
|
|
96
|
-
nominations: beatmapPage.nominations as number[],
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
+
import { supabase } from "../utils/supabase";
|
|
5
|
+
|
|
6
|
+
export const Schema = {
|
|
7
|
+
input: z.strictObject({
|
|
8
|
+
session: z.string(),
|
|
9
|
+
mapId: z.string(),
|
|
10
|
+
}),
|
|
11
|
+
output: z.object({
|
|
12
|
+
error: z.string().optional(),
|
|
13
|
+
beatmap: z
|
|
14
|
+
.object({
|
|
15
|
+
id: z.number().nullable().optional(),
|
|
16
|
+
nominations: z.array(z.number()).nullable().optional(),
|
|
17
|
+
playcount: z.number().nullable().optional(),
|
|
18
|
+
created_at: z.string().nullable().optional(),
|
|
19
|
+
updated_at: z.number().nullable().optional(),
|
|
20
|
+
difficulty: z.number().nullable().optional(),
|
|
21
|
+
noteCount: z.number().nullable().optional(),
|
|
22
|
+
length: z.number().nullable().optional(),
|
|
23
|
+
title: z.string().nullable().optional(),
|
|
24
|
+
ranked: z.boolean().nullable().optional(),
|
|
25
|
+
beatmapFile: z.string().nullable().optional(),
|
|
26
|
+
image: z.string().nullable().optional(),
|
|
27
|
+
starRating: z.number().nullable().optional(),
|
|
28
|
+
owner: z.number().nullable().optional(),
|
|
29
|
+
ownerUsername: z.string().nullable().optional(),
|
|
30
|
+
ownerAvatar: z.string().nullable().optional(),
|
|
31
|
+
status: z.string().nullable().optional(),
|
|
32
|
+
})
|
|
33
|
+
.optional(),
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export async function POST(request: Request): Promise<NextResponse> {
|
|
38
|
+
return protectedApi({
|
|
39
|
+
request,
|
|
40
|
+
schema: Schema,
|
|
41
|
+
authorization: () => {},
|
|
42
|
+
activity: handler,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function handler(
|
|
47
|
+
data: (typeof Schema)["input"]["_type"],
|
|
48
|
+
req: Request
|
|
49
|
+
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
50
|
+
let { data: beatmapPage, error: errorlast } = await supabase
|
|
51
|
+
.from("beatmapPages")
|
|
52
|
+
.select(
|
|
53
|
+
`
|
|
54
|
+
*,
|
|
55
|
+
beatmaps (
|
|
56
|
+
created_at,
|
|
57
|
+
playcount,
|
|
58
|
+
length,
|
|
59
|
+
ranked,
|
|
60
|
+
beatmapFile,
|
|
61
|
+
image,
|
|
62
|
+
starRating,
|
|
63
|
+
difficulty,
|
|
64
|
+
noteCount,
|
|
65
|
+
title
|
|
66
|
+
),
|
|
67
|
+
profiles (
|
|
68
|
+
username,
|
|
69
|
+
avatar_url
|
|
70
|
+
)
|
|
71
|
+
`
|
|
72
|
+
)
|
|
73
|
+
.eq("latestBeatmapHash", data.mapId)
|
|
74
|
+
.single();
|
|
75
|
+
|
|
76
|
+
if (!beatmapPage) return NextResponse.json({});
|
|
77
|
+
|
|
78
|
+
return NextResponse.json({
|
|
79
|
+
beatmap: {
|
|
80
|
+
playcount: beatmapPage.beatmaps?.playcount,
|
|
81
|
+
created_at: beatmapPage.created_at,
|
|
82
|
+
updated_at: beatmapPage.updated_at,
|
|
83
|
+
difficulty: beatmapPage.beatmaps?.difficulty,
|
|
84
|
+
noteCount: beatmapPage.beatmaps?.noteCount,
|
|
85
|
+
length: beatmapPage.beatmaps?.length,
|
|
86
|
+
title: beatmapPage.beatmaps?.title,
|
|
87
|
+
ranked: beatmapPage.beatmaps?.ranked,
|
|
88
|
+
beatmapFile: beatmapPage.beatmaps?.beatmapFile,
|
|
89
|
+
image: beatmapPage.beatmaps?.image,
|
|
90
|
+
starRating: beatmapPage.beatmaps?.starRating,
|
|
91
|
+
owner: beatmapPage.owner,
|
|
92
|
+
ownerUsername: beatmapPage.profiles?.username,
|
|
93
|
+
ownerAvatar: beatmapPage.profiles?.avatar_url,
|
|
94
|
+
id: beatmapPage.id,
|
|
95
|
+
status: beatmapPage.status,
|
|
96
|
+
nominations: beatmapPage.nominations as number[],
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { NextResponse } from "next/server";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
-
import { supabase } from "../utils/supabase";
|
|
5
|
-
|
|
6
|
-
export const Schema = {
|
|
7
|
-
input: z.strictObject({
|
|
8
|
-
session: z.string(),
|
|
9
|
-
mapId: z.string(),
|
|
10
|
-
}),
|
|
11
|
-
output: z.object({
|
|
12
|
-
error: z.string().optional(),
|
|
13
|
-
beatmap: z
|
|
14
|
-
.object({
|
|
15
|
-
starRating: z.number().nullable().optional(),
|
|
16
|
-
})
|
|
17
|
-
.optional(),
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export async function POST(request: Request): Promise<NextResponse> {
|
|
22
|
-
return protectedApi({
|
|
23
|
-
request,
|
|
24
|
-
schema: Schema,
|
|
25
|
-
authorization: () => {},
|
|
26
|
-
activity: handler,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function handler(
|
|
31
|
-
data: (typeof Schema)["input"]["_type"],
|
|
32
|
-
req: Request
|
|
33
|
-
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
34
|
-
let { data: beatmapPage, error: errorlast } = await supabase
|
|
35
|
-
.from("beatmapPages")
|
|
36
|
-
.select(
|
|
37
|
-
`
|
|
38
|
-
beatmaps (
|
|
39
|
-
starRating
|
|
40
|
-
)
|
|
41
|
-
`
|
|
42
|
-
)
|
|
43
|
-
.eq("latestBeatmapHash", data.mapId)
|
|
44
|
-
.single();
|
|
45
|
-
|
|
46
|
-
if (!beatmapPage) return NextResponse.json({});
|
|
47
|
-
|
|
48
|
-
return NextResponse.json({
|
|
49
|
-
beatmap: {
|
|
50
|
-
starRating: beatmapPage.beatmaps?.starRating,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { protectedApi } from "../utils/requestUtils";
|
|
4
|
+
import { supabase } from "../utils/supabase";
|
|
5
|
+
|
|
6
|
+
export const Schema = {
|
|
7
|
+
input: z.strictObject({
|
|
8
|
+
session: z.string(),
|
|
9
|
+
mapId: z.string(),
|
|
10
|
+
}),
|
|
11
|
+
output: z.object({
|
|
12
|
+
error: z.string().optional(),
|
|
13
|
+
beatmap: z
|
|
14
|
+
.object({
|
|
15
|
+
starRating: z.number().nullable().optional(),
|
|
16
|
+
})
|
|
17
|
+
.optional(),
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export async function POST(request: Request): Promise<NextResponse> {
|
|
22
|
+
return protectedApi({
|
|
23
|
+
request,
|
|
24
|
+
schema: Schema,
|
|
25
|
+
authorization: () => {},
|
|
26
|
+
activity: handler,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function handler(
|
|
31
|
+
data: (typeof Schema)["input"]["_type"],
|
|
32
|
+
req: Request
|
|
33
|
+
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
34
|
+
let { data: beatmapPage, error: errorlast } = await supabase
|
|
35
|
+
.from("beatmapPages")
|
|
36
|
+
.select(
|
|
37
|
+
`
|
|
38
|
+
beatmaps (
|
|
39
|
+
starRating
|
|
40
|
+
)
|
|
41
|
+
`
|
|
42
|
+
)
|
|
43
|
+
.eq("latestBeatmapHash", data.mapId)
|
|
44
|
+
.single();
|
|
45
|
+
|
|
46
|
+
if (!beatmapPage) return NextResponse.json({});
|
|
47
|
+
|
|
48
|
+
return NextResponse.json({
|
|
49
|
+
beatmap: {
|
|
50
|
+
starRating: beatmapPage.beatmaps?.starRating,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|