From d5269ee072c2b0ea3440dea4aa0336b677f20aa6 Mon Sep 17 00:00:00 2001 From: sahana Date: Wed, 29 Oct 2025 22:00:37 -0400 Subject: [PATCH 01/15] no pii for you :trolley: --- src/secrets.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/secrets.ts diff --git a/src/secrets.ts b/src/secrets.ts new file mode 100644 index 0000000..c7322d6 --- /dev/null +++ b/src/secrets.ts @@ -0,0 +1,4 @@ +export const secrets = { + rsvp_api_key: process.env.RSVP_AIRTABLE_API_KEY, + rsvp_base_id: process.env.RSVP_AIRTABLE_BASE_ID, +} \ No newline at end of file From 4eb02cc07fca65880d8203b21fdb5b7d02942eda Mon Sep 17 00:00:00 2001 From: sahana Date: Wed, 29 Oct 2025 22:01:41 -0400 Subject: [PATCH 02/15] bleh --- src/pages/api/git.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/api/git.ts b/src/pages/api/git.ts index 929f59e..6478a01 100644 --- a/src/pages/api/git.ts +++ b/src/pages/api/git.ts @@ -1,7 +1,5 @@ import { NextApiRequest, NextApiResponse } from "next"; -const branch = process.env.NODE_ENV === "production" ? "main" : "dev"; - let cache: { hash: string, message: string @@ -9,7 +7,7 @@ let cache: { export default async function handler(_req: NextApiRequest, res: NextApiResponse) { if (!cache) { - const githubRes = await fetch(`https://api.github.com/repos/hackclub/aces/commits/${branch}`) + const githubRes = await fetch(`https://api.github.com/repos/hackclub/aces/commits/production`) if (!githubRes.ok) throw new Error(`GitHub API error: ${githubRes.status}`) const json = await githubRes.json() cache = { From 85219a1c12be89cc2b4cef3e042f7070f81e7360 Mon Sep 17 00:00:00 2001 From: sahana Date: Wed, 29 Oct 2025 22:29:31 -0400 Subject: [PATCH 03/15] i am bad at coding --- src/pages/api/git.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/git.ts b/src/pages/api/git.ts index 6478a01..426d00f 100644 --- a/src/pages/api/git.ts +++ b/src/pages/api/git.ts @@ -7,7 +7,7 @@ let cache: { export default async function handler(_req: NextApiRequest, res: NextApiResponse) { if (!cache) { - const githubRes = await fetch(`https://api.github.com/repos/hackclub/aces/commits/production`) + const githubRes = await fetch(`https://api.github.com/repos/hackclub/aces/commits/main`) if (!githubRes.ok) throw new Error(`GitHub API error: ${githubRes.status}`) const json = await githubRes.json() cache = { From 79ee93d963126dfbf559bfd5938905c9c001ced4 Mon Sep 17 00:00:00 2001 From: sahana Date: Wed, 29 Oct 2025 23:13:46 -0400 Subject: [PATCH 04/15] start caching rsvps and move to local api for fast data --- bun.lock | 21 +++++++++++++++++++++ src/components/RSVP.tsx | 10 ++++++---- src/pages/api/rsvp.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/secrets.ts | 4 ---- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 src/pages/api/rsvp.ts delete mode 100644 src/secrets.ts diff --git a/bun.lock b/bun.lock index 20eac93..14c5e65 100644 --- a/bun.lock +++ b/bun.lock @@ -4,6 +4,7 @@ "": { "name": "aces-site", "dependencies": { + "airtable": "^0.12.2", "clsx": "^2.1.1", "next": "15.5.6", "react": "19.2.0", @@ -255,10 +256,16 @@ "@unrs/resolver-binding-win32-x64-msvc": ["@unrs/resolver-binding-win32-x64-msvc@1.11.1", "", { "os": "win32", "cpu": "x64" }, "sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g=="], + "abort-controller": ["abort-controller@3.0.0", "", { "dependencies": { "event-target-shim": "^5.0.0" } }, "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg=="], + + "abortcontroller-polyfill": ["abortcontroller-polyfill@1.7.8", "", {}, "sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ=="], + "acorn": ["acorn@8.15.0", "", { "bin": "bin/acorn" }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="], "acorn-jsx": ["acorn-jsx@5.3.2", "", { "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ=="], + "airtable": ["airtable@0.12.2", "", { "dependencies": { "@types/node": ">=8.0.0 <15", "abort-controller": "^3.0.0", "abortcontroller-polyfill": "^1.4.0", "lodash": "^4.17.21", "node-fetch": "^2.6.7" } }, "sha512-HS3VytUBTKj8A0vPl7DDr5p/w3IOGv6RXL0fv7eczOWAtj9Xe8ri4TAiZRXoOyo+Z/COADCj+oARFenbxhmkIg=="], + "ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="], "ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="], @@ -405,6 +412,8 @@ "esutils": ["esutils@2.0.3", "", {}, "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="], + "event-target-shim": ["event-target-shim@5.0.1", "", {}, "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="], + "fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="], "fast-glob": ["fast-glob@3.3.1", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" } }, "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg=="], @@ -585,6 +594,8 @@ "locate-path": ["locate-path@6.0.0", "", { "dependencies": { "p-locate": "^5.0.0" } }, "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw=="], + "lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="], + "lodash.merge": ["lodash.merge@4.6.2", "", {}, "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="], "loose-envify": ["loose-envify@1.4.0", "", { "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, "bin": "cli.js" }, "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q=="], @@ -615,6 +626,8 @@ "next": ["next@15.5.6", "", { "dependencies": { "@next/env": "15.5.6", "@swc/helpers": "0.5.15", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "15.5.6", "@next/swc-darwin-x64": "15.5.6", "@next/swc-linux-arm64-gnu": "15.5.6", "@next/swc-linux-arm64-musl": "15.5.6", "@next/swc-linux-x64-gnu": "15.5.6", "@next/swc-linux-x64-musl": "15.5.6", "@next/swc-win32-arm64-msvc": "15.5.6", "@next/swc-win32-x64-msvc": "15.5.6", "sharp": "^0.34.3" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.51.1", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": "dist/bin/next" }, "sha512-zTxsnI3LQo3c9HSdSf91O1jMNsEzIXDShXd4wVdg9y5shwLqBXi4ZtUUJyB86KGVSJLZx0PFONvO54aheGX8QQ=="], + "node-fetch": ["node-fetch@2.7.0", "", { "dependencies": { "whatwg-url": "^5.0.0" }, "peerDependencies": { "encoding": "^0.1.0" }, "optionalPeers": ["encoding"] }, "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="], + "object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="], "object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="], @@ -755,6 +768,8 @@ "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], + "tr46": ["tr46@0.0.3", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="], + "ts-api-utils": ["ts-api-utils@2.1.0", "", { "peerDependencies": { "typescript": ">=4.8.4" } }, "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ=="], "tsconfig-paths": ["tsconfig-paths@3.15.0", "", { "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.2", "minimist": "^1.2.6", "strip-bom": "^3.0.0" } }, "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg=="], @@ -783,6 +798,10 @@ "use-sync-external-store": ["use-sync-external-store@1.6.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="], + "webidl-conversions": ["webidl-conversions@3.0.1", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="], + + "whatwg-url": ["whatwg-url@5.0.0", "", { "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="], + "which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="], "which-boxed-primitive": ["which-boxed-primitive@1.1.1", "", { "dependencies": { "is-bigint": "^1.1.0", "is-boolean-object": "^1.2.1", "is-number-object": "^1.1.1", "is-string": "^1.1.1", "is-symbol": "^1.1.1" } }, "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA=="], @@ -809,6 +828,8 @@ "@typescript-eslint/typescript-estree/semver": ["semver@7.7.3", "", { "bin": "bin/semver.js" }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="], + "airtable/@types/node": ["@types/node@14.18.63", "", {}, "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ=="], + "eslint-import-resolver-node/debug": ["debug@3.2.7", "", { "dependencies": { "ms": "^2.1.1" } }, "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ=="], "eslint-module-utils/debug": ["debug@3.2.7", "", { "dependencies": { "ms": "^2.1.1" } }, "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ=="], diff --git a/src/components/RSVP.tsx b/src/components/RSVP.tsx index a575d2c..181f38d 100644 --- a/src/components/RSVP.tsx +++ b/src/components/RSVP.tsx @@ -1,15 +1,17 @@ +"use client" + import useSWR from "swr"; const fetcher = (url: string) => fetch(url).then(res => res.json()); export default function RSVP() { - const { data, error } = useSWR("https://aces.femboyin.tech/count", fetcher, { - refreshInterval: 60000, + const { data, error } = useSWR("/api/rsvp", fetcher, { + refreshInterval: 10000, revalidateOnFocus: false, }); if (error) return error!; - if (!data) return ... + if (!data || data.count == -1) return ... - return {data.record_count} + return {data.count} } \ No newline at end of file diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts new file mode 100644 index 0000000..1e6ab5c --- /dev/null +++ b/src/pages/api/rsvp.ts @@ -0,0 +1,38 @@ +import { NextApiRequest, NextApiResponse } from "next"; +import Airtable from "airtable"; + +async function getCount() { + let offset; + let count = 0; + + do { + const url = new URL(`https://api.airtable.com/v0/${process.env.RSVP_AIRTABLE_BASE_ID}/RSVPs`); + if (offset) url.searchParams.set("offset", offset); + + const res = await fetch(url, { + headers: { + Authorization: `Bearer ${process.env.RSVP_AIRTABLE_API_KEY}`, + }, + }); + + await new Promise((resolve) => setTimeout(resolve, 200)); + + const data = await res.json(); + count += data.records?.length ?? 0; + offset = data.offset; + } while (offset); + + return count +} + +let cached = { value: -1, updated: 0 }; + +setInterval(async () => { + const count = await getCount(); + cached = { value: count, updated: Date.now() }; + console.log("cached value", cached); +}, 5000); + +export default async function handler(_req: NextApiRequest, res: NextApiResponse) { + res.status(200).json({ count: cached.value }); +} \ No newline at end of file diff --git a/src/secrets.ts b/src/secrets.ts deleted file mode 100644 index c7322d6..0000000 --- a/src/secrets.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const secrets = { - rsvp_api_key: process.env.RSVP_AIRTABLE_API_KEY, - rsvp_base_id: process.env.RSVP_AIRTABLE_BASE_ID, -} \ No newline at end of file From c87d44bff5f930b0716b7d0c1a45bc57d6a00a63 Mon Sep 17 00:00:00 2001 From: sahana Date: Wed, 29 Oct 2025 23:17:12 -0400 Subject: [PATCH 05/15] why wasn't this commited? --- src/pages/api/rsvp.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index 1e6ab5c..b46b4d6 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -1,5 +1,4 @@ import { NextApiRequest, NextApiResponse } from "next"; -import Airtable from "airtable"; async function getCount() { let offset; From 7c9dceea5cc11e22c557a611fea130676271ab20 Mon Sep 17 00:00:00 2001 From: Sahana Date: Thu, 30 Oct 2025 07:50:26 -0400 Subject: [PATCH 06/15] Update rsvp.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/pages/api/rsvp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index b46b4d6..765bccc 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -21,7 +21,7 @@ async function getCount() { offset = data.offset; } while (offset); - return count + return count; } let cached = { value: -1, updated: 0 }; From afd51cc21bc316e8e6d90ca9d9805451c171bb96 Mon Sep 17 00:00:00 2001 From: Sahana Date: Thu, 30 Oct 2025 07:50:39 -0400 Subject: [PATCH 07/15] Update RSVP.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/components/RSVP.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/RSVP.tsx b/src/components/RSVP.tsx index 181f38d..43d557e 100644 --- a/src/components/RSVP.tsx +++ b/src/components/RSVP.tsx @@ -11,7 +11,7 @@ export default function RSVP() { }); if (error) return error!; - if (!data || data.count == -1) return ... + if (!data || data.count === -1) return ... return {data.count} } \ No newline at end of file From c986e07076b6aab2bea88bd8107d4c3669dd1f47 Mon Sep 17 00:00:00 2001 From: sahana Date: Thu, 30 Oct 2025 09:15:04 -0400 Subject: [PATCH 08/15] rsvp work --- src/pages/api/rsvp.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index 765bccc..f5f1bf0 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -13,12 +13,16 @@ async function getCount() { Authorization: `Bearer ${process.env.RSVP_AIRTABLE_API_KEY}`, }, }); - - await new Promise((resolve) => setTimeout(resolve, 200)); - + if (!res.ok) { + console.error(res.statusText); + await new Promise((resolve) => setTimeout(resolve, 200)); + continue + } const data = await res.json(); count += data.records?.length ?? 0; offset = data.offset; + + if (offset) await new Promise((resolve) => setTimeout(resolve, 200)); } while (offset); return count; From 9116ec2be47d56dad067f297171e89e772452d0a Mon Sep 17 00:00:00 2001 From: sahana Date: Thu, 30 Oct 2025 13:53:57 -0400 Subject: [PATCH 09/15] update subtitle --- src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 8bc50dc..1a22bb7 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -94,7 +94,7 @@ export default function Home() { />

Build your own digital board/card game, get a{" "} - grant to build it irl, and head to DC for{" "} + grant to make it real, and head to DC for{" "} AwesomeCon to showcase it, then stay for an in-person hackathon!

From e32f50f39634edc41539723004bc2210899def90 Mon Sep 17 00:00:00 2001 From: sahana Date: Thu, 30 Oct 2025 13:55:52 -0400 Subject: [PATCH 10/15] throw error to catch --- src/pages/api/rsvp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index f5f1bf0..e672910 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -16,7 +16,7 @@ async function getCount() { if (!res.ok) { console.error(res.statusText); await new Promise((resolve) => setTimeout(resolve, 200)); - continue + throw new Error(res.statusText); } const data = await res.json(); count += data.records?.length ?? 0; From 5c64eddb0016a514e2b0a5f1526eb96fb8680bc1 Mon Sep 17 00:00:00 2001 From: sahana Date: Fri, 31 Oct 2025 09:08:13 -0400 Subject: [PATCH 11/15] security :thumbup: --- src/pages/api/rsvp.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index e672910..14fdf02 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -31,10 +31,14 @@ async function getCount() { let cached = { value: -1, updated: 0 }; setInterval(async () => { - const count = await getCount(); - cached = { value: count, updated: Date.now() }; - console.log("cached value", cached); -}, 5000); + try { + const count = await getCount(); + cached = { value: count, updated: Date.now() }; + console.log("cached value", cached.value, "updatedAt", new Date(cached.updated).toISOString()); + } catch (err: unknown) { + console.error("getCount failed:", err); + } +}, 30000); export default async function handler(_req: NextApiRequest, res: NextApiResponse) { res.status(200).json({ count: cached.value }); From 7682a9d41615da3490de0945fc1d0a779845e32a Mon Sep 17 00:00:00 2001 From: Sahana Date: Fri, 31 Oct 2025 09:12:08 -0400 Subject: [PATCH 12/15] Update src/pages/api/rsvp.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/pages/api/rsvp.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index 14fdf02..e5b44a9 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -30,16 +30,20 @@ async function getCount() { let cached = { value: -1, updated: 0 }; -setInterval(async () => { - try { - const count = await getCount(); - cached = { value: count, updated: Date.now() }; - console.log("cached value", cached.value, "updatedAt", new Date(cached.updated).toISOString()); - } catch (err: unknown) { - console.error("getCount failed:", err); - } -}, 30000); +// Cache duration in milliseconds +const CACHE_DURATION = 30000; export default async function handler(_req: NextApiRequest, res: NextApiResponse) { + const now = Date.now(); + if (now - cached.updated > CACHE_DURATION) { + try { + const count = await getCount(); + cached = { value: count, updated: now }; + console.log("cached value", cached.value, "updatedAt", new Date(cached.updated).toISOString()); + } catch (err: unknown) { + console.error("getCount failed:", err); + // Optionally, you can return the old cached value or an error + } + } res.status(200).json({ count: cached.value }); } \ No newline at end of file From e4a2c02d2879eacc41bbe09e60bfc1fb4a681b86 Mon Sep 17 00:00:00 2001 From: Sahana Date: Fri, 31 Oct 2025 09:16:45 -0400 Subject: [PATCH 13/15] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/pages/api/rsvp.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index e5b44a9..9332417 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -15,7 +15,6 @@ async function getCount() { }); if (!res.ok) { console.error(res.statusText); - await new Promise((resolve) => setTimeout(resolve, 200)); throw new Error(res.statusText); } const data = await res.json(); From 684e4a109c50db14f77244206d212033c7c41ccf Mon Sep 17 00:00:00 2001 From: sahana Date: Fri, 31 Oct 2025 09:46:18 -0400 Subject: [PATCH 14/15] install :3 --- bun.lock | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/bun.lock b/bun.lock index 14c5e65..20eac93 100644 --- a/bun.lock +++ b/bun.lock @@ -4,7 +4,6 @@ "": { "name": "aces-site", "dependencies": { - "airtable": "^0.12.2", "clsx": "^2.1.1", "next": "15.5.6", "react": "19.2.0", @@ -256,16 +255,10 @@ "@unrs/resolver-binding-win32-x64-msvc": ["@unrs/resolver-binding-win32-x64-msvc@1.11.1", "", { "os": "win32", "cpu": "x64" }, "sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g=="], - "abort-controller": ["abort-controller@3.0.0", "", { "dependencies": { "event-target-shim": "^5.0.0" } }, "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg=="], - - "abortcontroller-polyfill": ["abortcontroller-polyfill@1.7.8", "", {}, "sha512-9f1iZ2uWh92VcrU9Y8x+LdM4DLj75VE0MJB8zuF1iUnroEptStw+DQ8EQPMUdfe5k+PkB1uUfDQfWbhstH8LrQ=="], - "acorn": ["acorn@8.15.0", "", { "bin": "bin/acorn" }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="], "acorn-jsx": ["acorn-jsx@5.3.2", "", { "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ=="], - "airtable": ["airtable@0.12.2", "", { "dependencies": { "@types/node": ">=8.0.0 <15", "abort-controller": "^3.0.0", "abortcontroller-polyfill": "^1.4.0", "lodash": "^4.17.21", "node-fetch": "^2.6.7" } }, "sha512-HS3VytUBTKj8A0vPl7DDr5p/w3IOGv6RXL0fv7eczOWAtj9Xe8ri4TAiZRXoOyo+Z/COADCj+oARFenbxhmkIg=="], - "ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="], "ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="], @@ -412,8 +405,6 @@ "esutils": ["esutils@2.0.3", "", {}, "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="], - "event-target-shim": ["event-target-shim@5.0.1", "", {}, "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="], - "fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="], "fast-glob": ["fast-glob@3.3.1", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" } }, "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg=="], @@ -594,8 +585,6 @@ "locate-path": ["locate-path@6.0.0", "", { "dependencies": { "p-locate": "^5.0.0" } }, "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw=="], - "lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="], - "lodash.merge": ["lodash.merge@4.6.2", "", {}, "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ=="], "loose-envify": ["loose-envify@1.4.0", "", { "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, "bin": "cli.js" }, "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q=="], @@ -626,8 +615,6 @@ "next": ["next@15.5.6", "", { "dependencies": { "@next/env": "15.5.6", "@swc/helpers": "0.5.15", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "15.5.6", "@next/swc-darwin-x64": "15.5.6", "@next/swc-linux-arm64-gnu": "15.5.6", "@next/swc-linux-arm64-musl": "15.5.6", "@next/swc-linux-x64-gnu": "15.5.6", "@next/swc-linux-x64-musl": "15.5.6", "@next/swc-win32-arm64-msvc": "15.5.6", "@next/swc-win32-x64-msvc": "15.5.6", "sharp": "^0.34.3" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.51.1", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": "dist/bin/next" }, "sha512-zTxsnI3LQo3c9HSdSf91O1jMNsEzIXDShXd4wVdg9y5shwLqBXi4ZtUUJyB86KGVSJLZx0PFONvO54aheGX8QQ=="], - "node-fetch": ["node-fetch@2.7.0", "", { "dependencies": { "whatwg-url": "^5.0.0" }, "peerDependencies": { "encoding": "^0.1.0" }, "optionalPeers": ["encoding"] }, "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="], - "object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="], "object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="], @@ -768,8 +755,6 @@ "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], - "tr46": ["tr46@0.0.3", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="], - "ts-api-utils": ["ts-api-utils@2.1.0", "", { "peerDependencies": { "typescript": ">=4.8.4" } }, "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ=="], "tsconfig-paths": ["tsconfig-paths@3.15.0", "", { "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.2", "minimist": "^1.2.6", "strip-bom": "^3.0.0" } }, "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg=="], @@ -798,10 +783,6 @@ "use-sync-external-store": ["use-sync-external-store@1.6.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="], - "webidl-conversions": ["webidl-conversions@3.0.1", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="], - - "whatwg-url": ["whatwg-url@5.0.0", "", { "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } }, "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="], - "which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="], "which-boxed-primitive": ["which-boxed-primitive@1.1.1", "", { "dependencies": { "is-bigint": "^1.1.0", "is-boolean-object": "^1.2.1", "is-number-object": "^1.1.1", "is-string": "^1.1.1", "is-symbol": "^1.1.1" } }, "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA=="], @@ -828,8 +809,6 @@ "@typescript-eslint/typescript-estree/semver": ["semver@7.7.3", "", { "bin": "bin/semver.js" }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="], - "airtable/@types/node": ["@types/node@14.18.63", "", {}, "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ=="], - "eslint-import-resolver-node/debug": ["debug@3.2.7", "", { "dependencies": { "ms": "^2.1.1" } }, "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ=="], "eslint-module-utils/debug": ["debug@3.2.7", "", { "dependencies": { "ms": "^2.1.1" } }, "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ=="], From 091130c295260ff86521429bf41bba4e1b2a9619 Mon Sep 17 00:00:00 2001 From: sahana Date: Fri, 31 Oct 2025 09:48:08 -0400 Subject: [PATCH 15/15] something something return the erorr --- src/pages/api/rsvp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/rsvp.ts b/src/pages/api/rsvp.ts index 9332417..ee5ab2e 100644 --- a/src/pages/api/rsvp.ts +++ b/src/pages/api/rsvp.ts @@ -41,7 +41,7 @@ export default async function handler(_req: NextApiRequest, res: NextApiResponse console.log("cached value", cached.value, "updatedAt", new Date(cached.updated).toISOString()); } catch (err: unknown) { console.error("getCount failed:", err); - // Optionally, you can return the old cached value or an error + res.status(500).json({ error: "couldnt get count" }); } } res.status(200).json({ count: cached.value });