rhythia-api 161.0.0 → 162.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.
@@ -7,6 +7,7 @@ export const Schema = {
7
7
  input: z.strictObject({
8
8
  session: z.string(),
9
9
  id: z.number(),
10
+ limit: z.number().default(10),
10
11
  }),
11
12
  output: z.object({
12
13
  error: z.string().optional(),
@@ -65,6 +66,9 @@ export async function handler(
65
66
  data: (typeof Schema)["input"]["_type"],
66
67
  req: Request
67
68
  ): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
69
+ if (data.limit > 100) {
70
+ return NextResponse.json({ error: "Limit breached" });
71
+ }
68
72
  let { data: scores1, error: errorlast } = await supabase
69
73
  .from("scores")
70
74
  .select(
@@ -80,7 +84,7 @@ export async function handler(
80
84
  .eq("userId", data.id)
81
85
  .eq("passed", true)
82
86
  .order("created_at", { ascending: false })
83
- .limit(10);
87
+ .limit(data.limit);
84
88
 
85
89
  let { data: scores2, error: errorsp } = await supabase
86
90
  .from("scores")
@@ -116,7 +120,7 @@ export async function handler(
116
120
  const values = Object.values(hashMap);
117
121
  let vals = values
118
122
  .sort((a, b) => b.awarded_sp - a.awarded_sp)
119
- .slice(0, 10)
123
+ .slice(0, data.limit)
120
124
  .map((e) => e.score);
121
125
 
122
126
  return NextResponse.json({
package/index.ts CHANGED
@@ -539,6 +539,7 @@ export const Schema = {
539
539
  input: z.strictObject({
540
540
  session: z.string(),
541
541
  id: z.number(),
542
+ limit: z.number().default(10),
542
543
  }),
543
544
  output: z.object({
544
545
  error: z.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "161.0.0",
3
+ "version": "162.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",