Files
web/apps/scandic-web/services/warmup/index.ts
Anton Gunnarsson f79ff9b570 Merged in chore/cleanup-unused (pull request #3461)
chore: Cleanup unused vars, exports, types

* Cleanup some unused exports

* Remove more

* Readd CampaignPageIncludedHotelsRef

* Add alias comment to procedure exports

* Remove unused exports


Approved-by: Linus Flood
2026-01-22 12:34:07 +00:00

59 lines
1.7 KiB
TypeScript

import { Lang } from "@scandic-hotels/common/constants/language"
import { warmupAutoComplete } from "./wamupAutoCompleteLocations"
import { warmupCountry } from "./warmupCountries"
import { warmupHotelData } from "./warmupHotelData"
import { warmupHotelIdsByCountry } from "./warmupHotelIdsByCountry"
import type { WarmupFunctionsKey } from "./warmupKeys"
export type WarmupFunction = () => Promise<WarmupResult>
type BaseWarmup = {
status: "skipped" | "completed"
}
type FailedWarmup = {
status: "error"
error: Error
}
export type WarmupResult = BaseWarmup | FailedWarmup
const warmupFunctions: Record<WarmupFunctionsKey, WarmupFunction> = {
countries_en: warmupCountry(Lang.en),
countries_da: warmupCountry(Lang.da),
countries_de: warmupCountry(Lang.de),
countries_fi: warmupCountry(Lang.fi),
countries_sv: warmupCountry(Lang.sv),
countries_no: warmupCountry(Lang.no),
hotelsByCountry: warmupHotelIdsByCountry(),
hotelData_en: warmupHotelData(Lang.en),
hotelData_da: warmupHotelData(Lang.da),
hotelData_de: warmupHotelData(Lang.de),
hotelData_fi: warmupHotelData(Lang.fi),
hotelData_sv: warmupHotelData(Lang.sv),
hotelData_no: warmupHotelData(Lang.no),
autoComplete_en: warmupAutoComplete(Lang.en),
autoComplete_da: warmupAutoComplete(Lang.da),
autoComplete_de: warmupAutoComplete(Lang.de),
autoComplete_fi: warmupAutoComplete(Lang.fi),
autoComplete_sv: warmupAutoComplete(Lang.sv),
autoComplete_no: warmupAutoComplete(Lang.no),
}
export async function warmup(key: WarmupFunctionsKey): Promise<WarmupResult> {
const func = warmupFunctions[key]
if (!func) {
return {
status: "error",
error: new Error(`Warmup function ${key} not found`),
}
}
return func()
}