24 lines
918 B
TypeScript
24 lines
918 B
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 async function getNeighborhoods(params: { city?: string; limit?: number } = {}): 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 });
|
|
}
|