Add brewery location query endpoints

This commit is contained in:
Aaron Po
2026-08-26 23:19:50 -04:00
parent d6306cbcba
commit eebb87811f
14 changed files with 491 additions and 61 deletions

View File

@@ -37,6 +37,12 @@ export interface Brewery {
location: BreweryLocation | null;
}
export interface SimplifiedBrewery {
breweryPostId: string;
breweryName: string;
location: BreweryLocation | null;
}
const fetchApi = async (path: string): Promise<Response> => {
try {
return await fetch(`${API_BASE_URL}${path}`);
@@ -66,6 +72,20 @@ export const getBreweries = async (limit?: number, offset?: number): Promise<Bre
return body.payload;
};
export const getBreweryLocations = async (): Promise<SimplifiedBrewery[]> => {
const res = await fetchApi('/api/brewery/locations');
if (!res.ok) {
throw data(`Failed to load brewery locations (${res.status}).`, {
status: res.status,
statusText: res.statusText,
});
}
const body: ApiResponse<SimplifiedBrewery[]> = await res.json();
return body.payload;
};
export const getBreweryById = async (id: string): Promise<Brewery | null> => {
const res = await fetchApi(`/api/brewery/${encodeURIComponent(id)}`);