mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-03 22:44:35 -04:00
16 lines
597 B
TypeScript
16 lines
597 B
TypeScript
import {ValidatedAPIParams} from 'common/api/schema'
|
|
import {geodbFetch} from 'common/geodb'
|
|
|
|
import {APIHandler} from './helpers/endpoint'
|
|
|
|
export const searchLocationEndpoint: APIHandler<'search-location'> = async (body) => {
|
|
return await searchLocation(body)
|
|
}
|
|
|
|
export async function searchLocation(body: ValidatedAPIParams<'search-location'>) {
|
|
const {term, limit} = body
|
|
const endpoint = `/cities?namePrefix=${term}&limit=${limit ?? 10}&offset=0&sort=-population`
|
|
// const endpoint = `/countries?namePrefix=${term}&limit=${limit ?? 10}&offset=0`
|
|
return await geodbFetch(endpoint)
|
|
}
|