rhythia-api 170.0.0 → 172.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/createClan.ts +11 -0
- package/api/getClan.ts +0 -2
- package/api/getLeaderboard.ts +12 -1
- package/api/getProfile.ts +26 -21
- package/index.ts +14 -2
- package/package.json +1 -1
- package/types/database.ts +3 -0
package/api/createClan.ts
CHANGED
|
@@ -66,5 +66,16 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
66
66
|
acronym: data.acronym.toUpperCase(),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
let { data: queryClanData, error: clanError } = await supabase
|
|
70
|
+
.from("clans")
|
|
71
|
+
.select("*")
|
|
72
|
+
.eq("owner", queryUserData.id)
|
|
73
|
+
.single();
|
|
74
|
+
|
|
75
|
+
await supabase.from("profiles").upsert({
|
|
76
|
+
id: queryUserData.id,
|
|
77
|
+
clan: queryClanData?.id,
|
|
78
|
+
});
|
|
79
|
+
|
|
69
80
|
return NextResponse.json({});
|
|
70
81
|
}
|
package/api/getClan.ts
CHANGED
package/api/getLeaderboard.ts
CHANGED
|
@@ -28,6 +28,13 @@ export const Schema = {
|
|
|
28
28
|
skill_points: z.number().nullable(),
|
|
29
29
|
spin_skill_points: z.number().nullable(),
|
|
30
30
|
total_score: z.number().nullable(),
|
|
31
|
+
clans: z
|
|
32
|
+
.object({
|
|
33
|
+
id: z.number(),
|
|
34
|
+
acronym: z.string(),
|
|
35
|
+
})
|
|
36
|
+
.optional()
|
|
37
|
+
.nullable(),
|
|
31
38
|
})
|
|
32
39
|
)
|
|
33
40
|
.optional(),
|
|
@@ -92,7 +99,10 @@ export async function getLeaderboard(
|
|
|
92
99
|
.select("ban", { count: "exact", head: true })
|
|
93
100
|
.neq("ban", "excluded");
|
|
94
101
|
|
|
95
|
-
let query = supabase
|
|
102
|
+
let query = supabase
|
|
103
|
+
.from("profiles")
|
|
104
|
+
.select("*,clans:clan(id, acronym)")
|
|
105
|
+
.neq("ban", "excluded");
|
|
96
106
|
|
|
97
107
|
if (flag) {
|
|
98
108
|
query.eq("flag", flag);
|
|
@@ -120,6 +130,7 @@ export async function getLeaderboard(
|
|
|
120
130
|
spin_skill_points: user.spin_skill_points,
|
|
121
131
|
total_score: user.total_score,
|
|
122
132
|
username: user.username,
|
|
133
|
+
clans: user.clans as any,
|
|
123
134
|
})),
|
|
124
135
|
};
|
|
125
136
|
}
|
package/api/getProfile.ts
CHANGED
|
@@ -33,6 +33,13 @@ export const Schema = {
|
|
|
33
33
|
total_score: z.number().nullable(),
|
|
34
34
|
position: z.number().nullable(),
|
|
35
35
|
is_online: z.boolean(),
|
|
36
|
+
clans: z
|
|
37
|
+
.object({
|
|
38
|
+
id: z.number(),
|
|
39
|
+
acronym: z.string(),
|
|
40
|
+
})
|
|
41
|
+
.optional()
|
|
42
|
+
.nullable(),
|
|
36
43
|
})
|
|
37
44
|
.optional(),
|
|
38
45
|
}),
|
|
@@ -57,7 +64,7 @@ export async function handler(
|
|
|
57
64
|
if (data.id !== undefined && data.id !== null) {
|
|
58
65
|
let { data: queryData, error } = await supabase
|
|
59
66
|
.from("profiles")
|
|
60
|
-
.select(
|
|
67
|
+
.select(`*,clans:clan(id,acronym)`)
|
|
61
68
|
.eq("id", data.id);
|
|
62
69
|
|
|
63
70
|
console.log(profiles, error);
|
|
@@ -84,25 +91,23 @@ export async function handler(
|
|
|
84
91
|
|
|
85
92
|
if (!queryData?.length) {
|
|
86
93
|
const geo = geolocation(req);
|
|
87
|
-
const data = await supabase
|
|
88
|
-
.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
105
|
-
.select();
|
|
94
|
+
const data = await supabase.from("profiles").upsert({
|
|
95
|
+
uid: user.id,
|
|
96
|
+
about_me: "",
|
|
97
|
+
avatar_url:
|
|
98
|
+
"https://rhthia-avatars.s3.eu-central-003.backblazeb2.com/user-avatar-1725309193296-72002e6b-321c-4f60-a692-568e0e75147d",
|
|
99
|
+
badges: [],
|
|
100
|
+
username: `${user.user_metadata.full_name.slice(0, 20)}${Math.round(
|
|
101
|
+
Math.random() * 900000 + 100000
|
|
102
|
+
)}`,
|
|
103
|
+
computedUsername: `${user.user_metadata.full_name.slice(
|
|
104
|
+
0,
|
|
105
|
+
20
|
|
106
|
+
)}${Math.round(Math.random() * 900000 + 100000)}`.toLowerCase(),
|
|
107
|
+
flag: (geo.country || "US").toUpperCase(),
|
|
108
|
+
created_at: Date.now(),
|
|
109
|
+
}).select(`
|
|
110
|
+
*,clans:clan(id,acronym)`);
|
|
106
111
|
|
|
107
112
|
profiles = data.data!;
|
|
108
113
|
} else {
|
|
@@ -127,7 +132,7 @@ export async function handler(
|
|
|
127
132
|
// Query to count how many players have more skill points than the specific player
|
|
128
133
|
const { count: playersWithMorePoints, error: rankError } = await supabase
|
|
129
134
|
.from("profiles")
|
|
130
|
-
.select(
|
|
135
|
+
.select(`*`, { count: "exact", head: true })
|
|
131
136
|
.neq("ban", "excluded")
|
|
132
137
|
.gt("skill_points", user.skill_points);
|
|
133
138
|
|
package/index.ts
CHANGED
|
@@ -395,8 +395,6 @@ export const Schema = {
|
|
|
395
395
|
skill_points: z.number().nullable(),
|
|
396
396
|
squares_hit: z.number().nullable(),
|
|
397
397
|
total_score: z.number().nullable(),
|
|
398
|
-
position: z.number().nullable(),
|
|
399
|
-
is_online: z.boolean(),
|
|
400
398
|
})
|
|
401
399
|
),
|
|
402
400
|
}),
|
|
@@ -431,6 +429,13 @@ export const Schema = {
|
|
|
431
429
|
skill_points: z.number().nullable(),
|
|
432
430
|
spin_skill_points: z.number().nullable(),
|
|
433
431
|
total_score: z.number().nullable(),
|
|
432
|
+
clans: z
|
|
433
|
+
.object({
|
|
434
|
+
id: z.number(),
|
|
435
|
+
acronym: z.string(),
|
|
436
|
+
})
|
|
437
|
+
.optional()
|
|
438
|
+
.nullable(),
|
|
434
439
|
})
|
|
435
440
|
)
|
|
436
441
|
.optional(),
|
|
@@ -510,6 +515,13 @@ export const Schema = {
|
|
|
510
515
|
total_score: z.number().nullable(),
|
|
511
516
|
position: z.number().nullable(),
|
|
512
517
|
is_online: z.boolean(),
|
|
518
|
+
clans: z
|
|
519
|
+
.object({
|
|
520
|
+
id: z.number(),
|
|
521
|
+
acronym: z.string(),
|
|
522
|
+
})
|
|
523
|
+
.optional()
|
|
524
|
+
.nullable(),
|
|
513
525
|
})
|
|
514
526
|
.optional(),
|
|
515
527
|
}),
|
package/package.json
CHANGED
package/types/database.ts
CHANGED
|
@@ -156,6 +156,7 @@ export type Database = {
|
|
|
156
156
|
clans: {
|
|
157
157
|
Row: {
|
|
158
158
|
acronym: string | null
|
|
159
|
+
allowed_users: Json
|
|
159
160
|
avatar_url: string | null
|
|
160
161
|
created_at: string
|
|
161
162
|
description: string | null
|
|
@@ -165,6 +166,7 @@ export type Database = {
|
|
|
165
166
|
}
|
|
166
167
|
Insert: {
|
|
167
168
|
acronym?: string | null
|
|
169
|
+
allowed_users?: Json
|
|
168
170
|
avatar_url?: string | null
|
|
169
171
|
created_at?: string
|
|
170
172
|
description?: string | null
|
|
@@ -174,6 +176,7 @@ export type Database = {
|
|
|
174
176
|
}
|
|
175
177
|
Update: {
|
|
176
178
|
acronym?: string | null
|
|
179
|
+
allowed_users?: Json
|
|
177
180
|
avatar_url?: string | null
|
|
178
181
|
created_at?: string
|
|
179
182
|
description?: string | null
|