refactor(network): simplify base URL and clean up validators

- Updated the base URL to a fixed production endpoint, removing the conditional logic for development.
- Commented out Location and Organizer validations in the eventValidator for future consideration.
- Added a console log in getUserImages to assist with backend response tracking.
This commit is contained in:
2025-04-14 11:37:29 +02:00
parent 3c1f6ba40f
commit 6ae2458186

View File

@ -19,9 +19,11 @@ type BaseRequestParams = Partial<{
method: "GET" | "POST";
}>;
export const base = import.meta.env.DEV
? "http://localhost:3040"
: "https://haystack.johncosta.tech";
// export const base = import.meta.env.DEV
// ? "http://localhost:3040"
// : "https://haystack.johncosta.tech";
export const base = "https://haystack.johncosta.tech";
const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => {
return new Request(`${base}/${path}`, {
@ -89,9 +91,9 @@ const eventValidator = strictObject({
EndDateTime: nullable(pipe(string())),
Description: nullable(string()),
LocationID: nullable(pipe(string(), uuid())),
Location: nullable(locationValidator),
// Location: nullable(locationValidator),
OrganizerID: nullable(pipe(string(), uuid())),
Organizer: nullable(contactValidator),
// Organizer: nullable(contactValidator),
});
const noteValidator = strictObject({
@ -136,6 +138,8 @@ export const getUserImages = async (): Promise<UserImage[]> => {
const res = await fetch(request).then((res) => res.json());
console.log("BACKEND RESPONSE: ", res);
return parse(getUserImagesResponseValidator, res);
};