fix(network): update base URL for development and production environments

- Changed the base URL to use localhost for development and the production URL for other environments.
- Added Location validation back into the eventValidator and removed commented-out code for clarity.
- Cleaned up debugging logs in getUserImages function.
This commit is contained in:
2025-04-14 10:56:32 +02:00
parent 0eff145f02
commit 3c1f6ba40f

View File

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