rhythia-api 157.0.0 → 159.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.
@@ -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
+ }
@@ -19,6 +19,7 @@ export const Schema = {
19
19
  mapHash: z.string(),
20
20
  speed: z.number(),
21
21
  mods: z.array(z.string()),
22
+ additionalData: z.record(z.string(), z.any()),
22
23
  }),
23
24
  }),
24
25
  output: z.object({
@@ -68,6 +69,8 @@ export async function handler({
68
69
  hits: data.hits,
69
70
  mapHash: data.mapHash,
70
71
  speed: data.speed,
72
+ mods: data.mods,
73
+ additionalData: data.additionalData,
71
74
  })
72
75
  ) {
73
76
  return NextResponse.json(
@@ -158,11 +161,11 @@ export async function handler({
158
161
 
159
162
  let multiplierMod = 1;
160
163
  if (data.mods.includes("mod_hardrock")) {
161
- multiplierMod *= 1.075;
164
+ multiplierMod *= 1.12;
162
165
  }
163
166
 
164
167
  if (data.mods.includes("mod_nofail")) {
165
- multiplierMod *= 0.5;
168
+ multiplierMod *= Math.pow(0.95, data.misses);
166
169
  }
167
170
 
168
171
  if (beatmaps.starRating) {
@@ -186,6 +189,7 @@ export async function handler({
186
189
  misses: data.misses,
187
190
  awarded_sp: Math.round(awarded_sp * 100) / 100,
188
191
  speed: data.speed,
192
+ mods: data.mods,
189
193
  });
190
194
  console.log("p2");
191
195
 
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
  /*
@@ -665,6 +686,7 @@ export const Schema = {
665
686
  mapHash: z.string(),
666
687
  speed: z.number(),
667
688
  mods: z.array(z.string()),
689
+ additionalData: z.record(z.string(), z.any()),
668
690
  }),
669
691
  }),
670
692
  output: z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "157.0.0",
3
+ "version": "159.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": "^1.207.9",
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