sendou.ink/app/features/front-page/loaders/index.server.ts
Kalle 1c9dcacbf2
Join many teams & front page changelog (#1880)
* Initial

* Progress

* Changelog initial

* Progress

* E2E test
2024-09-14 12:31:05 +03:00

33 lines
844 B
TypeScript

import cachified from "@epic-web/cachified";
import {
ONE_HOUR_IN_MS,
TEN_MINUTES_IN_MS,
TWO_HOURS_IN_MS,
} from "~/constants";
import * as Changelog from "~/features/front-page/core/Changelog.server";
import * as TournamentRepository from "~/features/tournament/TournamentRepository.server";
import { cache, ttl } from "~/utils/cache.server";
export const loader = async () => {
return {
tournaments: await cachified({
key: "tournament-showcase",
cache,
ttl: ttl(TEN_MINUTES_IN_MS),
staleWhileRevalidate: ttl(ONE_HOUR_IN_MS),
async getFreshValue() {
return TournamentRepository.forShowcase();
},
}),
changelog: await cachified({
key: "changelog",
cache,
ttl: ttl(ONE_HOUR_IN_MS),
staleWhileRevalidate: ttl(TWO_HOURS_IN_MS),
async getFreshValue() {
return Changelog.get();
},
}),
};
};