rhythia-api 157.0.0 → 158.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/getBeatmapStarRating.ts +53 -0
- package/api/submitScore.ts +4 -2
- package/index.ts +21 -0
- package/package.json +2 -2
- package/types/database.ts +9 -0
|
@@ -0,0 +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
|
+
}
|
package/api/submitScore.ts
CHANGED
|
@@ -68,6 +68,7 @@ export async function handler({
|
|
|
68
68
|
hits: data.hits,
|
|
69
69
|
mapHash: data.mapHash,
|
|
70
70
|
speed: data.speed,
|
|
71
|
+
mods: data.mods,
|
|
71
72
|
})
|
|
72
73
|
) {
|
|
73
74
|
return NextResponse.json(
|
|
@@ -158,11 +159,11 @@ export async function handler({
|
|
|
158
159
|
|
|
159
160
|
let multiplierMod = 1;
|
|
160
161
|
if (data.mods.includes("mod_hardrock")) {
|
|
161
|
-
multiplierMod *= 1.
|
|
162
|
+
multiplierMod *= 1.12;
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
if (data.mods.includes("mod_nofail")) {
|
|
165
|
-
multiplierMod *= 0.
|
|
166
|
+
multiplierMod *= Math.pow(0.95, data.misses);
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
if (beatmaps.starRating) {
|
|
@@ -186,6 +187,7 @@ export async function handler({
|
|
|
186
187
|
misses: data.misses,
|
|
187
188
|
awarded_sp: Math.round(awarded_sp * 100) / 100,
|
|
188
189
|
speed: data.speed,
|
|
190
|
+
mods: data.mods,
|
|
189
191
|
});
|
|
190
192
|
console.log("p2");
|
|
191
193
|
|
package/index.ts
CHANGED
|
@@ -300,6 +300,27 @@ import { Schema as GetBeatmaps } from "./api/getBeatmaps"
|
|
|
300
300
|
export { Schema as SchemaGetBeatmaps } from "./api/getBeatmaps"
|
|
301
301
|
export const getBeatmaps = handleApi({url:"/api/getBeatmaps",...GetBeatmaps})
|
|
302
302
|
|
|
303
|
+
// ./api/getBeatmapStarRating.ts API
|
|
304
|
+
|
|
305
|
+
/*
|
|
306
|
+
export const Schema = {
|
|
307
|
+
input: z.strictObject({
|
|
308
|
+
session: z.string(),
|
|
309
|
+
mapId: z.string(),
|
|
310
|
+
}),
|
|
311
|
+
output: z.object({
|
|
312
|
+
error: z.string().optional(),
|
|
313
|
+
beatmap: z
|
|
314
|
+
.object({
|
|
315
|
+
starRating: z.number().nullable().optional(),
|
|
316
|
+
})
|
|
317
|
+
.optional(),
|
|
318
|
+
}),
|
|
319
|
+
};*/
|
|
320
|
+
import { Schema as GetBeatmapStarRating } from "./api/getBeatmapStarRating"
|
|
321
|
+
export { Schema as SchemaGetBeatmapStarRating } from "./api/getBeatmapStarRating"
|
|
322
|
+
export const getBeatmapStarRating = handleApi({url:"/api/getBeatmapStarRating",...GetBeatmapStarRating})
|
|
323
|
+
|
|
303
324
|
// ./api/getLeaderboard.ts API
|
|
304
325
|
|
|
305
326
|
/*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rhythia-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "158.0.0",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update": "bun ./scripts/update.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"osu-standard-stable": "^5.0.0",
|
|
40
40
|
"sharp": "^0.33.5",
|
|
41
41
|
"simple-git": "^3.25.0",
|
|
42
|
-
"supabase": "^
|
|
42
|
+
"supabase": "^2.0.0",
|
|
43
43
|
"tsx": "^4.17.0",
|
|
44
44
|
"utf-8-validate": "^6.0.4",
|
|
45
45
|
"zod": "^3.23.8"
|
package/types/database.ts
CHANGED
|
@@ -184,8 +184,10 @@ export type Database = {
|
|
|
184
184
|
created_at: number | null
|
|
185
185
|
flag: string | null
|
|
186
186
|
id: number
|
|
187
|
+
mu_rank: number
|
|
187
188
|
play_count: number | null
|
|
188
189
|
profile_image: string | null
|
|
190
|
+
sigma_rank: number | null
|
|
189
191
|
skill_points: number | null
|
|
190
192
|
squares_hit: number | null
|
|
191
193
|
total_score: number | null
|
|
@@ -203,8 +205,10 @@ export type Database = {
|
|
|
203
205
|
created_at?: number | null
|
|
204
206
|
flag?: string | null
|
|
205
207
|
id?: number
|
|
208
|
+
mu_rank?: number
|
|
206
209
|
play_count?: number | null
|
|
207
210
|
profile_image?: string | null
|
|
211
|
+
sigma_rank?: number | null
|
|
208
212
|
skill_points?: number | null
|
|
209
213
|
squares_hit?: number | null
|
|
210
214
|
total_score?: number | null
|
|
@@ -222,8 +226,10 @@ export type Database = {
|
|
|
222
226
|
created_at?: number | null
|
|
223
227
|
flag?: string | null
|
|
224
228
|
id?: number
|
|
229
|
+
mu_rank?: number
|
|
225
230
|
play_count?: number | null
|
|
226
231
|
profile_image?: string | null
|
|
232
|
+
sigma_rank?: number | null
|
|
227
233
|
skill_points?: number | null
|
|
228
234
|
squares_hit?: number | null
|
|
229
235
|
total_score?: number | null
|
|
@@ -240,6 +246,7 @@ export type Database = {
|
|
|
240
246
|
created_at: string
|
|
241
247
|
id: number
|
|
242
248
|
misses: number | null
|
|
249
|
+
mods: Json
|
|
243
250
|
passed: boolean | null
|
|
244
251
|
replayHwid: string | null
|
|
245
252
|
songId: string | null
|
|
@@ -252,6 +259,7 @@ export type Database = {
|
|
|
252
259
|
created_at?: string
|
|
253
260
|
id?: number
|
|
254
261
|
misses?: number | null
|
|
262
|
+
mods?: Json
|
|
255
263
|
passed?: boolean | null
|
|
256
264
|
replayHwid?: string | null
|
|
257
265
|
songId?: string | null
|
|
@@ -264,6 +272,7 @@ export type Database = {
|
|
|
264
272
|
created_at?: string
|
|
265
273
|
id?: number
|
|
266
274
|
misses?: number | null
|
|
275
|
+
mods?: Json
|
|
267
276
|
passed?: boolean | null
|
|
268
277
|
replayHwid?: string | null
|
|
269
278
|
songId?: string | null
|