Chore/refactor hotel trpc routes * chore(SW-3519): refactor trpc hotel routers * chore(SW-3519): refactor trpc hotel routers * refactor * merge * Merge branch 'master' of bitbucket.org:scandic-swap/web into chore/refactor-hotel-trpc-routes Approved-by: Linus Flood
30 lines
735 B
TypeScript
30 lines
735 B
TypeScript
import { getServiceToken } from "@scandic-hotels/common/tokenManager"
|
|
import { getCountries } from "@scandic-hotels/trpc/routers/hotels/services/getCountries"
|
|
|
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
|
|
|
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",
|
|
}
|
|
}
|