GymLog: Gym- & Körpergewicht-Tracker — PWA mit Passkey-Login

Frontend: Static-SPA (Vanilla JS) — Dashboard, Wochenplan mit Per-Tag-Umplanung,
geführter Workout-Flow (Körpergewicht-Abfrage, Set-Logging, Rest-Timer, PR-Erkennung,
Gewichts-Bestätigung pro Übung), Activity-Heatmap, Kraft- & Gewichts-Charts,
Übungs-Bibliothek (1324 Übungen, autoplay GIFs), Swipe-Sheets, PWA/offline.

Backend: Node + @simplewebauthn — Passkey-Registrierung/-Login (Face ID),
HMAC-Session-Cookies, Per-User-State-Sync mit JSON-File-Storage.

Übungsdaten aus hasaneyldrm/exercises-dataset (Medien via scripts/fetch-media.sh).
This commit is contained in:
Duarte Santos committed 2026-07-18 22:53:08 +02:00
commit 29f5f64f8e
15 files changed
+2476

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
/* GymLog service worker — network-first for app shell, cache-first for media */
const CACHE = 'gymlog-v5';
const SHELL = ['./', 'index.html', 'style.css?v=5', 'app.js?v=5', 'data.js?v=5', 'manifest.json'];
self.addEventListener('install', e => {
e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)).then(() => self.skipWaiting()));
});
self.addEventListener('activate', e => {
e.waitUntil(caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
).then(() => self.clients.claim()));
});
self.addEventListener('fetch', e => {
const url = new URL(e.request.url);
if (e.request.method !== 'GET' || url.origin !== location.origin) return;
if (url.pathname.startsWith('/api/')) return; // auth/data requests: never cache
const isMedia = url.pathname.includes('/img/') || url.pathname.includes('/gif/');
if (isMedia) {
// cache-first: exercise images never change
e.respondWith(caches.open(CACHE).then(c => c.match(e.request).then(hit =>
hit || fetch(e.request).then(res => { if (res.ok) c.put(e.request, res.clone()); return res; })
)));
} else {
// network-first: shell updates propagate, offline falls back to cache
e.respondWith(fetch(e.request).then(res => {
if (res.ok) caches.open(CACHE).then(c => c.put(e.request, res.clone()));
return res;
}).catch(() => caches.match(e.request, { ignoreSearch: false })
.then(hit => hit || caches.match('index.html'))));
}
});