28 lines
721 B
TypeScript
28 lines
721 B
TypeScript
import { getAutoCompleteDestinationsData } from "@/server/routers/autocomplete/destinations"
|
|
import { getServiceToken } from "@/server/tokenManager"
|
|
|
|
import type { Lang } from "@/constants/languages"
|
|
import type { WarmupFunction, WarmupResult } from "."
|
|
|
|
export const warmupAutoComplete =
|
|
(lang: Lang): WarmupFunction =>
|
|
async (): Promise<WarmupResult> => {
|
|
try {
|
|
const serviceToken = await getServiceToken()
|
|
await getAutoCompleteDestinationsData({
|
|
lang,
|
|
serviceToken: serviceToken.access_token,
|
|
warmup: true,
|
|
})
|
|
} catch (error) {
|
|
return {
|
|
status: "error",
|
|
error: error as Error,
|
|
}
|
|
}
|
|
|
|
return {
|
|
status: "completed",
|
|
}
|
|
}
|