Merged in fix/warmup-autocomplete-data (pull request #2212)
warmup autocomplete data * warmup autocomplete data Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user