rhythia-api 170.0.0 → 171.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/getProfile.ts +26 -21
- package/index.ts +7 -2
- package/package.json +1 -1
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/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
|
}),
|
|
@@ -510,6 +508,13 @@ export const Schema = {
|
|
|
510
508
|
total_score: z.number().nullable(),
|
|
511
509
|
position: z.number().nullable(),
|
|
512
510
|
is_online: z.boolean(),
|
|
511
|
+
clans: z
|
|
512
|
+
.object({
|
|
513
|
+
id: z.number(),
|
|
514
|
+
acronym: z.string(),
|
|
515
|
+
})
|
|
516
|
+
.optional()
|
|
517
|
+
.nullable(),
|
|
513
518
|
})
|
|
514
519
|
.optional(),
|
|
515
520
|
}),
|