36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import "server-only";
|
|
import { winofyFetch, type PaginatedResponse } from "./winofy";
|
|
import type { City, Neighborhood } from "@/types/api";
|
|
|
|
export async function getCities(): Promise<City[]> {
|
|
const res = await winofyFetch<PaginatedResponse<City>>("/v1/cities/", { auth: false, params: { limit: 100 } });
|
|
return res.results;
|
|
}
|
|
|
|
export async function getCity(uuid: string): Promise<City> {
|
|
return winofyFetch<City>(`/v1/cities/${uuid}/`, { auth: false });
|
|
}
|
|
|
|
export interface GetNeighborhoodsParams {
|
|
city?: string;
|
|
/**
|
|
* Forwarded to the API for forward-compatibility, but confirmed against
|
|
* staging (2026-08-22) to currently have no effect — the endpoint returns
|
|
* the same unfiltered results with or without it. Callers must still filter
|
|
* client-side (see NeighborhoodSearch) until the backend actually supports it.
|
|
*/
|
|
search?: string;
|
|
limit?: number;
|
|
}
|
|
|
|
export async function getNeighborhoods(params: GetNeighborhoodsParams = {}): Promise<Neighborhood[]> {
|
|
const res = await winofyFetch<PaginatedResponse<Neighborhood>>("/v1/neighborhoods/", {
|
|
auth: false,
|
|
params: { limit: 200, ...params },
|
|
});
|
|
return res.results;
|
|
}
|
|
|
|
export async function getNeighborhood(uuid: string): Promise<Neighborhood> {
|
|
return winofyFetch<Neighborhood>(`/v1/neighborhoods/${uuid}/`, { auth: false });
|
|
}
|