mirror of
https://git.moonleay.net/Websites/liljudd-website.git
synced 2025-07-26 11:22:04 +02:00
Fix: use intergers for discord ids
This commit is contained in:
parent
ffaf8d989e
commit
95fee833a1
9 changed files with 151 additions and 181 deletions
|
@ -5,7 +5,7 @@ import { guilds, matches } from "~/drizzle/schema";
|
|||
import { BasicAuth } from "~/lib/auth";
|
||||
import { buildMatches } from "~/lib/responseBuilders";
|
||||
import { ErrorResponse, Res } from "~/lib/responses";
|
||||
import { zodMatch } from "~/lib/zod";
|
||||
import { zodId, zodMatch } from "~/lib/zod";
|
||||
import { APIResponse, RequestBody } from "~/types/backend";
|
||||
|
||||
type Path = "/api/{guildId}/matches";
|
||||
|
@ -22,17 +22,22 @@ export const GET = async (
|
|||
return ErrorResponse("UNAUTHORIZED");
|
||||
}
|
||||
|
||||
let guildId: number;
|
||||
try {
|
||||
guildId = zodId.parse(event.params.guildId);
|
||||
} catch (e) {
|
||||
return ErrorResponse("BAD_REQUEST", JSON.stringify(e));
|
||||
}
|
||||
|
||||
const guild = await db.query.guilds
|
||||
.findFirst({
|
||||
where: eq(guilds.id, event.params.guildId),
|
||||
where: eq(guilds.id, guildId),
|
||||
with: {
|
||||
matches: true,
|
||||
},
|
||||
})
|
||||
.execute();
|
||||
|
||||
console.log(event.params.guildId, guild);
|
||||
|
||||
if (!guild) return ErrorResponse("NOT_FOUND");
|
||||
|
||||
if (guild.matches.length < 1) return Res("NO_CONTENT", null);
|
||||
|
@ -55,17 +60,22 @@ export const POST = async (
|
|||
return ErrorResponse("UNAUTHORIZED");
|
||||
}
|
||||
|
||||
let guildId: number;
|
||||
try {
|
||||
guildId = zodId.parse(event.params.guildId);
|
||||
} catch (e) {
|
||||
return ErrorResponse("BAD_REQUEST", JSON.stringify(e));
|
||||
}
|
||||
|
||||
const guild = await db.query.guilds
|
||||
.findFirst({
|
||||
where: eq(guilds.id, event.params.guildId),
|
||||
where: eq(guilds.id, guildId),
|
||||
with: {
|
||||
matches: true,
|
||||
},
|
||||
})
|
||||
.execute();
|
||||
|
||||
console.log(event.params.guildId, guild);
|
||||
|
||||
if (!guild) return ErrorResponse("NOT_FOUND");
|
||||
|
||||
const unparsedBody = await new Response(event.request.body).json();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue