Skip to content

Commit

Permalink
Add revalidations
Browse files Browse the repository at this point in the history
  • Loading branch information
switz committed Aug 21, 2023
1 parent 5b2f698 commit 6ca5168
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const fetchShow = async (
): Promise<Partial<Tape>> => {
if (!slug || !year || !displayDate) return { sources: [] };

const parsed = (await ky(
`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}/${displayDate}`
).json()) as Tape;
const parsed = (await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}/${displayDate}`, {
next: { revalidate: 60 * 5 },
}).json()) as Tape;

return parsed;
};
Expand Down
4 changes: 3 additions & 1 deletion src/app/(main)/(secondary)/today/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { groupBy } from '../../../../lib/utils';
import { Artist, Day } from '../../../../types';

export default async function Page() {
const data: Day[] = await fetch(`${API_DOMAIN}/api/v2/shows/today`).then((res) => res.json());
const data: Day[] = await fetch(`${API_DOMAIN}/api/v2/shows/today`, {
next: { revalidate: 60 * 5 }, // seconds
}).then((res) => res.json());

const artists: Artist[] = data.map((day: Day) => ({
...day,
Expand Down
4 changes: 3 additions & 1 deletion src/app/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { API_DOMAIN } from '../lib/constants';
import { Artist } from '@/types';

export const fetchArtists = async (): Promise<Artist[]> => {
const parsed = await ky(`${API_DOMAIN}/api/v2/artists`)
const parsed = await ky(`${API_DOMAIN}/api/v2/artists`, {
next: { revalidate: 60 * 5 },
})
.json()
.catch((err) => {
console.error('artists fetch error', err);
Expand Down
4 changes: 3 additions & 1 deletion src/components/ShowsColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import Tag from './Tag';
const fetchShows = async (slug?: string, year?: string): Promise<ArtistShows | undefined> => {
if (!slug || !year) return undefined;

const parsed: ArtistShows = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}`).json();
const parsed: ArtistShows = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}`, {
next: { revalidate: 60 * 5 },
}).json();

return parsed;
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/YearsColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import Row from './Row';
const fetchYears = async (slug?: string): Promise<Year[]> => {
if (!slug) return [];

const parsed: Year[] = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years`).json();
const parsed: Year[] = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years`, {
next: { revalidate: 60 * 5 },
}).json();

return parsed;
};
Expand Down

0 comments on commit 6ca5168

Please sign in to comment.