Fix match-details

This commit is contained in:
Kalle 2022-03-12 14:02:21 +02:00
parent 3b343e066e
commit 6310bbc823
4 changed files with 7 additions and 3 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ node_modules
/.cache
/server/build
/public/build
/build
/build
backup.sql

View File

@ -37,7 +37,7 @@ export const detailedMapSchema = z.object({
winners: teamInfoSchema,
losers: teamInfoSchema,
date: z.string().refine((val) => {
const d = new Date(Number(val));
const d = new Date(val);
if (Number.isNaN(d.getTime())) {
return false;
}

View File

@ -99,7 +99,9 @@ export async function parseRequestFormData<T extends z.ZodTypeAny>({
// False alarm
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return schema.parse(
useBody ? request.body : Object.fromEntries(await request.formData())
useBody
? await request.json()
: Object.fromEntries(await request.formData())
);
} catch (e) {
if (e instanceof z.ZodError) {

View File

@ -16,6 +16,7 @@
"migration:apply:prod": "npx prisma migrate deploy",
"seed": "node --experimental-specifier-resolution=node --loader ts-node/esm -r tsconfig-paths/register prisma/seed",
"seed:reset": "npx prisma migrate reset --force --skip-generate",
"restore": "psql -d prod_copy -f backup.sql",
"lint:ts": "eslint . --ext .ts,.tsx",
"lint:styles": "stylelint \"app/styles/**/*.css\"",
"lsf": "npm run lint:styles -- --fix",