From fb9966fc25255617091025b386509daeaaf5f939 Mon Sep 17 00:00:00 2001 From: Owen Rees Date: Thu, 15 Jun 2023 13:24:45 +0200 Subject: [PATCH] db cache updated --- app/api/tournaments/france/route.ts | 15 ++-- app/tournois/page.tsx | 2 +- components/TournamentMap.tsx | 2 +- package-lock.json | 130 +++++++++++++++------------- package.json | 8 +- 5 files changed, 87 insertions(+), 70 deletions(-) diff --git a/app/api/tournaments/france/route.ts b/app/api/tournaments/france/route.ts index a0f4f4c..8645541 100644 --- a/app/api/tournaments/france/route.ts +++ b/app/api/tournaments/france/route.ts @@ -1,5 +1,4 @@ import clientPromise from "@/lib/mongodb"; -import { cache } from "react"; import { dateOrderingFrance } from "@/utils/dbDateOrdering"; /** @@ -7,16 +6,20 @@ import { dateOrderingFrance } from "@/utils/dbDateOrdering"; * @route /api/tournaments/france * @internal */ -export const revalidate = 86400; -export const GET = cache(async function () { +// TODO add headers to response content-type application/json +export const revalidate = 3600; // revalidate cache every 6 hours +async function GET() { + const headers = { + "Content-Type": "application/json", + }; try { const client = await clientPromise; const db = client.db("tournamentsFranceDB"); const data = await dateOrderingFrance(db); - return new Response(JSON.stringify(data), { status: 200 }); + return new Response(JSON.stringify(data), { status: 200, headers }); } catch (error) { - return new Response(JSON.stringify(error), { status: 500 }); + return new Response(JSON.stringify(error), { status: 500, headers }); } -}); +} diff --git a/app/tournois/page.tsx b/app/tournois/page.tsx index cb1c196..f5176a1 100644 --- a/app/tournois/page.tsx +++ b/app/tournois/page.tsx @@ -4,7 +4,7 @@ import Layout from "@/components/Layout"; import TournamentTable from "@/components/TournamentTable"; import { dateOrderingFrance } from "@/utils/dbDateOrdering"; -export const revalidate = 86400; // cache for 24 hours +export const revalidate = 3600; // revalidate cache every 6 hours /** * Imports the tournament map component, ensuring CSR only. diff --git a/components/TournamentMap.tsx b/components/TournamentMap.tsx index 692710c..e8a420a 100644 --- a/components/TournamentMap.tsx +++ b/components/TournamentMap.tsx @@ -24,7 +24,7 @@ export default function TournamentMap({ tournamentData }: TournamentDataProps) { return (
=10.13.0" } }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" + }, "node_modules/global-dirs": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-3.0.1.tgz", @@ -7309,16 +7314,17 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" }, "node_modules/next": { - "version": "13.4.3", - "resolved": "https://registry.npmjs.org/next/-/next-13.4.3.tgz", - "integrity": "sha512-FV3pBrAAnAIfOclTvncw9dDohyeuEEXPe5KNcva91anT/rdycWbgtu3IjUj4n5yHnWK8YEPo0vrUecHmnmUNbA==", + "version": "13.4.5", + "resolved": "https://registry.npmjs.org/next/-/next-13.4.5.tgz", + "integrity": "sha512-pfNsRLVM9e5Y1/z02VakJRfD6hMQkr24FaN2xc9GbcZDBxoOgiNAViSg5cXwlWCoMhtm4U315D7XYhgOr96Q3Q==", "dependencies": { - "@next/env": "13.4.3", + "@next/env": "13.4.5", "@swc/helpers": "0.5.1", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", "postcss": "8.4.14", "styled-jsx": "5.1.1", + "watchpack": "2.4.0", "zod": "3.21.4" }, "bin": { @@ -7328,20 +7334,19 @@ "node": ">=16.8.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.4.3", - "@next/swc-darwin-x64": "13.4.3", - "@next/swc-linux-arm64-gnu": "13.4.3", - "@next/swc-linux-arm64-musl": "13.4.3", - "@next/swc-linux-x64-gnu": "13.4.3", - "@next/swc-linux-x64-musl": "13.4.3", - "@next/swc-win32-arm64-msvc": "13.4.3", - "@next/swc-win32-ia32-msvc": "13.4.3", - "@next/swc-win32-x64-msvc": "13.4.3" + "@next/swc-darwin-arm64": "13.4.5", + "@next/swc-darwin-x64": "13.4.5", + "@next/swc-linux-arm64-gnu": "13.4.5", + "@next/swc-linux-arm64-musl": "13.4.5", + "@next/swc-linux-x64-gnu": "13.4.5", + "@next/swc-linux-x64-musl": "13.4.5", + "@next/swc-win32-arm64-msvc": "13.4.5", + "@next/swc-win32-ia32-msvc": "13.4.5", + "@next/swc-win32-x64-msvc": "13.4.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "fibers": ">= 3.1.0", - "node-sass": "^6.0.0 || ^7.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", "sass": "^1.3.0" @@ -7353,9 +7358,6 @@ "fibers": { "optional": true }, - "node-sass": { - "optional": true - }, "sass": { "optional": true } @@ -9671,6 +9673,18 @@ "makeerror": "1.0.12" } }, + "node_modules/watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "dependencies": { + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/webidl-conversions": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", diff --git a/package.json b/package.json index ae31019..08d93ef 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,14 @@ "@vercel/analytics": "^1.0.1", "autoprefixer": "10.4.14", "eslint": "8.41.0", - "eslint-config-next": "13.4.3", + "eslint-config-next": "^13.4.5", "leaflet": "^1.9.4", "leaflet-defaulticon-compatibility": "^0.1.1", "mongodb": "^5.5.0", - "next": "13.4.3", + "next": "^13.4.5", "postcss": "8.4.23", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-icons": "^4.9.0", "react-leaflet": "^4.2.1", "sharp": "^0.32.1",