rhythia-api 154.0.0 → 156.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.
@@ -29,6 +29,23 @@ export const Schema = {
29
29
  status: z.string().nullable().optional(),
30
30
  })
31
31
  ),
32
+ topUsers: z.array(
33
+ z.object({
34
+ username: z.string(),
35
+ id: z.number(),
36
+ avatar_url: z.string(),
37
+ skill_points: z.number(),
38
+ })
39
+ ),
40
+ lastComments: z.array(
41
+ z.object({
42
+ owner: z.number(),
43
+ content: z.string(),
44
+ username: z.string(),
45
+ beatmapTitle: z.string(),
46
+ beatmapPage: z.number(),
47
+ })
48
+ ),
32
49
  }),
33
50
  };
34
51
 
@@ -77,6 +94,28 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
77
94
  .order("created_at", { ascending: false })
78
95
  .limit(4);
79
96
 
97
+ let { data: topUsers } = await supabase
98
+ .from("profiles")
99
+ .select("*")
100
+ .neq("ban", "excluded")
101
+ .order("skill_points", { ascending: false })
102
+ .limit(3);
103
+
104
+ let { data: comments } = await supabase
105
+ .from("beatmapPageComments")
106
+ .select(
107
+ `
108
+ *,
109
+ beatmapPages!inner(
110
+ *
111
+ ),
112
+ profiles!inner(
113
+ username
114
+ )`
115
+ )
116
+ .order("created_at", { ascending: false })
117
+ .limit(5);
118
+
80
119
  const countScoresQuery = await supabase
81
120
  .from("scores")
82
121
  .select("*", { count: "exact", head: true });
@@ -103,5 +142,18 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
103
142
  status: e.status,
104
143
  nominations: e.nominations as number[],
105
144
  })),
145
+ topUsers: topUsers?.map((e) => ({
146
+ username: e.username,
147
+ id: e.id,
148
+ avatar_url: e.avatar_url,
149
+ skill_points: e.skill_points,
150
+ })),
151
+ lastComments: comments?.map((e) => ({
152
+ owner: e.owner,
153
+ content: e.content,
154
+ username: e.profiles.username,
155
+ beatmapTitle: e.beatmapPages.title,
156
+ beatmapPage: e.beatmapPages.id,
157
+ })),
106
158
  });
107
159
  }
@@ -0,0 +1,23 @@
1
+ import { NextResponse } from "next/server";
2
+ import z from "zod";
3
+ import { protectedApi, validUser } from "../utils/requestUtils";
4
+
5
+ export const Schema = {
6
+ input: z.strictObject({}),
7
+ output: z.object({
8
+ time: z.number(),
9
+ }),
10
+ };
11
+
12
+ export async function POST(request: Request) {
13
+ return protectedApi({
14
+ request,
15
+ schema: Schema,
16
+ authorization: validUser,
17
+ activity: handler,
18
+ });
19
+ }
20
+
21
+ export async function handler(data: (typeof Schema)["input"]["_type"]) {
22
+ return NextResponse.json({ time: Date.now() });
23
+ }
package/index.ts CHANGED
@@ -438,6 +438,23 @@ export const Schema = {
438
438
  status: z.string().nullable().optional(),
439
439
  })
440
440
  ),
441
+ topUsers: z.array(
442
+ z.object({
443
+ username: z.string(),
444
+ id: z.number(),
445
+ avatar_url: z.string(),
446
+ skill_points: z.number(),
447
+ })
448
+ ),
449
+ lastComments: z.array(
450
+ z.object({
451
+ owner: z.number(),
452
+ content: z.string(),
453
+ username: z.string(),
454
+ beatmapTitle: z.string(),
455
+ beatmapPage: z.number(),
456
+ })
457
+ ),
441
458
  }),
442
459
  };*/
443
460
  import { Schema as GetPublicStats } from "./api/getPublicStats"
@@ -477,6 +494,19 @@ import { Schema as GetScore } from "./api/getScore"
477
494
  export { Schema as SchemaGetScore } from "./api/getScore"
478
495
  export const getScore = handleApi({url:"/api/getScore",...GetScore})
479
496
 
497
+ // ./api/getTimestamp.ts API
498
+
499
+ /*
500
+ export const Schema = {
501
+ input: z.strictObject({}),
502
+ output: z.object({
503
+ time: z.number(),
504
+ }),
505
+ };*/
506
+ import { Schema as GetTimestamp } from "./api/getTimestamp"
507
+ export { Schema as SchemaGetTimestamp } from "./api/getTimestamp"
508
+ export const getTimestamp = handleApi({url:"/api/getTimestamp",...GetTimestamp})
509
+
480
510
  // ./api/getUserScores.ts API
481
511
 
482
512
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "154.0.0",
3
+ "version": "156.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",