Merged in feature/warmup (pull request #1887)
* unified warmup function Approved-by: Linus Flood
This commit is contained in:
28
apps/scandic-web/services/warmup/warmupCountries.ts
Normal file
28
apps/scandic-web/services/warmup/warmupCountries.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { getCountries } from "@/server/routers/hotels/utils"
|
||||
import { getServiceToken } from "@/server/tokenManager"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { WarmupFunction, WarmupResult } from "."
|
||||
|
||||
export const warmupCountry =
|
||||
(lang: Lang): WarmupFunction =>
|
||||
async (): Promise<WarmupResult> => {
|
||||
try {
|
||||
const serviceToken = await getServiceToken()
|
||||
|
||||
await getCountries({
|
||||
lang: 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