mirror of
https://git.moonleay.net/Websites/liljudd-website.git
synced 2025-07-26 11:22:04 +02:00
Fix: Using bigint and added backend testing
This commit is contained in:
parent
ed6195e1e2
commit
89507f8412
20 changed files with 830 additions and 292 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 { zodId, zodMatch } from "~/lib/zod";
|
||||
import { zodBigIntId, zodMatch } from "~/lib/zod";
|
||||
import { APIResponse, RequestBody } from "~/types/backend";
|
||||
|
||||
type Path = "/api/{guildId}/matches";
|
||||
|
@ -22,9 +22,9 @@ export const GET = async (
|
|||
return ErrorResponse("UNAUTHORIZED");
|
||||
}
|
||||
|
||||
let guildId: number;
|
||||
let guildId: bigint;
|
||||
try {
|
||||
guildId = zodId.parse(event.params.guildId);
|
||||
guildId = zodBigIntId.parse(event.params.guildId);
|
||||
} catch (e) {
|
||||
return ErrorResponse("BAD_REQUEST", JSON.stringify(e));
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ export const POST = async (
|
|||
return ErrorResponse("UNAUTHORIZED");
|
||||
}
|
||||
|
||||
let guildId: number;
|
||||
let guildId: bigint;
|
||||
try {
|
||||
guildId = zodId.parse(event.params.guildId);
|
||||
guildId = zodBigIntId.parse(event.params.guildId);
|
||||
} catch (e) {
|
||||
return ErrorResponse("BAD_REQUEST", JSON.stringify(e));
|
||||
}
|
||||
|
@ -94,8 +94,13 @@ export const POST = async (
|
|||
);
|
||||
|
||||
await db.insert(matches).values({
|
||||
...body.match,
|
||||
guildId: guild.id,
|
||||
channelId: BigInt(body.match.channelId),
|
||||
roleId: BigInt(body.match.roleId),
|
||||
createrId: BigInt(body.match.createrId),
|
||||
messageId: BigInt(body.match.messageId),
|
||||
matchType: body.match.matchType,
|
||||
opponentName: body.match.opponentName,
|
||||
utc_ts: new Date(body.match.utc_ts),
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue