Merged in fix/cache-time-hotels-test-env (pull request #1194)

fix: cache time 5 minutes for hotels data in test env

* fix: cache time 5 minutes for hotels data in test env
This commit is contained in:
Linus Flood
2025-01-21 09:29:09 +00:00
parent 7ac200bd7c
commit d02dc51dcc
2 changed files with 11 additions and 2 deletions

9
env/server.ts vendored
View File

@@ -1,6 +1,8 @@
import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"
const TWENTYFOUR_HOURS = 24 * 60 * 60
export const env = createEnv({
/**
* Due to t3-env only checking typeof window === "undefined"
@@ -137,6 +139,12 @@ export const env = createEnv({
process.env.CMS_ENVIRONMENT === "test" ? 5 * 60 : 30 * 60
)
.default(30 * 60),
CACHE_TIME_HOTELS: z
.number()
.transform(() =>
process.env.CMS_ENVIRONMENT === "test" ? 5 * 60 : TWENTYFOUR_HOURS
)
.default(TWENTYFOUR_HOURS),
},
emptyStringAsUndefined: true,
runtimeEnv: {
@@ -204,5 +212,6 @@ export const env = createEnv({
SENTRY_ENVIRONMENT: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
SENTRY_SERVER_SAMPLERATE: process.env.SENTRY_SERVER_SAMPLERATE,
CACHE_TIME_HOTELDATA: process.env.CACHE_TIME_HOTELDATA,
CACHE_TIME_HOTELS: process.env.CACHE_TIME_HOTELS,
},
})

View File

@@ -716,7 +716,7 @@ export const hotelQueryRouter = router({
Authorization: `Bearer ${ctx.serviceToken}`,
},
next: {
revalidate: TWENTYFOUR_HOURS,
revalidate: env.CACHE_TIME_HOTELS,
},
}
@@ -1198,7 +1198,7 @@ export const hotelQueryRouter = router({
Authorization: `Bearer ${ctx.serviceToken}`,
},
next: {
revalidate: TWENTYFOUR_HOURS,
revalidate: env.CACHE_TIME_HOTELS,
},
},
params