rhythia-api 195.0.0 → 197.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/createInvite.ts +13 -1
- package/api/createSupporter.ts +2 -2
- package/api/getLeaderboard.ts +2 -0
- package/api/getVerified.ts +41 -0
- package/api/submitScore.ts +4 -4
- package/index.ts +14 -0
- package/package.json +1 -1
package/api/createInvite.ts
CHANGED
|
@@ -45,7 +45,19 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
let { data: clanQuery, error: clanError } = await supabase
|
|
49
|
+
.from("clans")
|
|
50
|
+
.select("*")
|
|
51
|
+
.eq("id", queryUserData.clan || -1)
|
|
52
|
+
.single();
|
|
53
|
+
|
|
54
|
+
if (!clanQuery) {
|
|
55
|
+
return NextResponse.json({
|
|
56
|
+
error: "You're not in a clan",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (data.resourceId !== (clanQuery.owner || -1).toString()) {
|
|
49
61
|
return NextResponse.json({
|
|
50
62
|
error: "You can't create invite for a clan that you aren't owner of.",
|
|
51
63
|
});
|
package/api/createSupporter.ts
CHANGED
|
@@ -98,7 +98,7 @@ export async function handler(
|
|
|
98
98
|
let { data: queryData, error } = await supabase
|
|
99
99
|
.from("profiles")
|
|
100
100
|
.select("*")
|
|
101
|
-
.eq("computedUsername", data.data.support_note)
|
|
101
|
+
.eq("computedUsername", data.data.support_note.toLowerCase())
|
|
102
102
|
.single();
|
|
103
103
|
|
|
104
104
|
if (queryData) {
|
|
@@ -110,7 +110,7 @@ export async function handler(
|
|
|
110
110
|
let { data: queryData, error } = await supabase
|
|
111
111
|
.from("profiles")
|
|
112
112
|
.select("*")
|
|
113
|
-
.eq("computedUsername", data.data.supporter_name)
|
|
113
|
+
.eq("computedUsername", data.data.supporter_name.toLowerCase())
|
|
114
114
|
.single();
|
|
115
115
|
|
|
116
116
|
if (queryData) {
|
package/api/getLeaderboard.ts
CHANGED
|
@@ -28,6 +28,7 @@ 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
|
+
verified: z.boolean().nullable(),
|
|
31
32
|
clans: z
|
|
32
33
|
.object({
|
|
33
34
|
id: z.number(),
|
|
@@ -131,6 +132,7 @@ export async function getLeaderboard(
|
|
|
131
132
|
total_score: user.total_score,
|
|
132
133
|
username: user.username,
|
|
133
134
|
clans: user.clans as any,
|
|
135
|
+
verified: user.verified,
|
|
134
136
|
})),
|
|
135
137
|
};
|
|
136
138
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { protectedApi, validUser } from "../utils/requestUtils";
|
|
4
|
+
import { supabase } from "../utils/supabase";
|
|
5
|
+
import { User } from "@supabase/supabase-js";
|
|
6
|
+
import { getUserBySession } from "../utils/getUserBySession";
|
|
7
|
+
|
|
8
|
+
export const Schema = {
|
|
9
|
+
input: z.strictObject({
|
|
10
|
+
session: z.string(),
|
|
11
|
+
}),
|
|
12
|
+
output: z.strictObject({}),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export async function POST(request: Request): Promise<NextResponse> {
|
|
16
|
+
return protectedApi({
|
|
17
|
+
request,
|
|
18
|
+
schema: Schema,
|
|
19
|
+
authorization: () => {},
|
|
20
|
+
activity: handler,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function handler(
|
|
25
|
+
data: (typeof Schema)["input"]["_type"]
|
|
26
|
+
): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
|
|
27
|
+
const user = (await getUserBySession(data.session)) as User;
|
|
28
|
+
let { data: queryData, error } = await supabase
|
|
29
|
+
.from("profiles")
|
|
30
|
+
.select("*")
|
|
31
|
+
.eq("uid", user.id)
|
|
32
|
+
.single();
|
|
33
|
+
|
|
34
|
+
if (!queryData) {
|
|
35
|
+
NextResponse.json({});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log("CHEATER: " + queryData);
|
|
39
|
+
|
|
40
|
+
return NextResponse.json({});
|
|
41
|
+
}
|
package/api/submitScore.ts
CHANGED
|
@@ -112,7 +112,7 @@ export async function handler({
|
|
|
112
112
|
{
|
|
113
113
|
error: "User doesn't exist",
|
|
114
114
|
},
|
|
115
|
-
{ status:
|
|
115
|
+
{ status: 400 }
|
|
116
116
|
);
|
|
117
117
|
|
|
118
118
|
console.log(userData);
|
|
@@ -143,7 +143,7 @@ export async function handler({
|
|
|
143
143
|
{
|
|
144
144
|
error: "Map not submitted",
|
|
145
145
|
},
|
|
146
|
-
{ status:
|
|
146
|
+
{ status: 400 }
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -152,7 +152,7 @@ export async function handler({
|
|
|
152
152
|
{
|
|
153
153
|
error: "Map not submitted",
|
|
154
154
|
},
|
|
155
|
-
{ status:
|
|
155
|
+
{ status: 400 }
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -162,7 +162,7 @@ export async function handler({
|
|
|
162
162
|
{
|
|
163
163
|
error: "Wrong map",
|
|
164
164
|
},
|
|
165
|
-
{ status:
|
|
165
|
+
{ status: 400 }
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
|
package/index.ts
CHANGED
|
@@ -743,6 +743,7 @@ export const Schema = {
|
|
|
743
743
|
skill_points: z.number().nullable(),
|
|
744
744
|
spin_skill_points: z.number().nullable(),
|
|
745
745
|
total_score: z.number().nullable(),
|
|
746
|
+
verified: z.boolean().nullable(),
|
|
746
747
|
clans: z
|
|
747
748
|
.object({
|
|
748
749
|
id: z.number(),
|
|
@@ -1053,6 +1054,19 @@ import { Schema as GetUserScores } from "./api/getUserScores"
|
|
|
1053
1054
|
export { Schema as SchemaGetUserScores } from "./api/getUserScores"
|
|
1054
1055
|
export const getUserScores = handleApi({url:"/api/getUserScores",...GetUserScores})
|
|
1055
1056
|
|
|
1057
|
+
// ./api/getVerified.ts API
|
|
1058
|
+
|
|
1059
|
+
/*
|
|
1060
|
+
export const Schema = {
|
|
1061
|
+
input: z.strictObject({
|
|
1062
|
+
session: z.string(),
|
|
1063
|
+
}),
|
|
1064
|
+
output: z.strictObject({}),
|
|
1065
|
+
};*/
|
|
1066
|
+
import { Schema as GetVerified } from "./api/getVerified"
|
|
1067
|
+
export { Schema as SchemaGetVerified } from "./api/getVerified"
|
|
1068
|
+
export const getVerified = handleApi({url:"/api/getVerified",...GetVerified})
|
|
1069
|
+
|
|
1056
1070
|
// ./api/nominateMap.ts API
|
|
1057
1071
|
|
|
1058
1072
|
/*
|