Fix: Finished Backend

This commit is contained in:
aronmal 2024-02-26 21:46:33 +01:00
parent 6b388729d9
commit ffaf8d989e
Signed by: aronmal
GPG key ID: 816B7707426FC612
30 changed files with 1478 additions and 873 deletions

37
src/lib/zod.ts Normal file
View file

@ -0,0 +1,37 @@
import moment from "moment-timezone";
import { z } from "zod";
export const zodId = z
.string()
.refine((value) => /^\d{7,20}$/.test(value), "Invalid ID supplied");
export const zodTpMessages = z.object({
channelId: zodId,
messageIds: z.object({
"0": zodId.nullable(),
"1": zodId.nullable(),
"2": zodId.nullable(),
"3": zodId.nullable(),
"4": zodId.nullable(),
"5": zodId.nullable(),
"6": zodId.nullable(),
}),
});
export const zodMatch = z.object({
match: z.object({
channelId: zodId,
createrId: zodId,
messageId: zodId,
roleId: zodId,
matchType: z.string(),
opponentName: z.string(),
utc_ts: z.string().datetime(),
}),
timezone: z
.string()
.refine(
(value) => moment.tz.names().includes(value),
"Unknown timezone supplied",
),
});