Merged in feature/warmup (pull request #1887)
* unified warmup function Approved-by: Linus Flood
This commit is contained in:
31
apps/scandic-web/services/warmup/warmupHotelData.ts
Normal file
31
apps/scandic-web/services/warmup/warmupHotelData.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { env } from "@/env/server"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import type { Lang } from "@/constants/languages"
|
||||
import type { WarmupFunction, WarmupResult } from "."
|
||||
|
||||
export const warmupHotelData =
|
||||
(lang: Lang): WarmupFunction =>
|
||||
async (): Promise<WarmupResult> => {
|
||||
if (!env.ENABLE_WARMUP_HOTEL) {
|
||||
return {
|
||||
status: "skipped",
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await serverClient().hotel.hotels.getDestinationsMapData({
|
||||
lang,
|
||||
warmup: true,
|
||||
})
|
||||
} catch (error) {
|
||||
return {
|
||||
status: "error",
|
||||
error: error as Error,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: "completed",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user