Update packages

This commit is contained in:
Timothy Armes
2024-10-21 15:19:28 +02:00
parent 75fd05a3d7
commit 1c7ad63e03
33 changed files with 1822 additions and 1351 deletions
+8 -8
View File
@@ -5,7 +5,7 @@ import { z } from "zod";
import { fetchTournamentResultsSchema } from "@/schemas";
import { errorLog } from "@/utils/logger";
import { action } from "./safeAction";
import { actionClient } from "./safeAction";
const dbSchema = z.array(
z.object({
@@ -106,9 +106,10 @@ const reportFetchError = async (url: string, error: any) => {
}
};
export const fetchTournamentResults = action(
fetchTournamentResultsSchema,
async (input) => {
export const fetchTournamentResults = actionClient
.schema(fetchTournamentResultsSchema)
.action(async (input) => {
const { id } = input.parsedInput;
try {
const headers = new Headers();
const apiKey = process.env.RESULTS_API_KEY;
@@ -118,7 +119,7 @@ export const fetchTournamentResults = action(
}
const rawResults = await fetch(
`${process.env.RESULTS_SCRAPER_URL}${input.id}`,
`${process.env.RESULTS_SCRAPER_URL}${id}`,
{
headers: headers,
},
@@ -155,9 +156,8 @@ export const fetchTournamentResults = action(
})),
);
} catch (error) {
reportFetchError(input.id, error);
reportFetchError(id, error);
errorLog(JSON.stringify(error, null, 2));
throw error;
}
},
);
});