FastAPI backend (Python 3.11, MSSQL ODBC for SambaPOS, Azure DI OCR),
kitchen_db on central PG. React/TS/Vite frontend with navy sidebar layout.
Backend: auth.py (APP_SLUG=kitchen, SimpleNamespace — archive routes use
.kitchen_id/.is_admin without modification), main.py (51 migrations, scheduler,
internal router for KDS bookings feed), api/internal.py, full archive API
(31 routers: invoices, recipes, menus, sambapos, resos, newbook, disputes,
purchase_orders, etc.), models, migrations, OCR pipeline.
kitchen_id pinned to 1 (B1 — single hotel).
Frontend: AuthGate (app=kitchen, token shim for archive compat — B5b pending),
Layout (navy sidebar, 6 sections, Lucide icons, teal --app-primary),
App.tsx (Outlet pattern, UploadApp outside Layout), index.css (full :root block).
strict: false — archive components have type issues; build clean.
Note: 45 archive components call fetch('/api/...') without /kitchen/ prefix
(B5b). Runtime 404s; deferred until after initial testing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
const CACHE_NAME = 'kitchen-app-v3'
|
|
const SHELL_URLS = [
|
|
'/manifest.json',
|
|
'/kds-manifest.json',
|
|
]
|
|
|
|
self.addEventListener('install', (event) => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(SHELL_URLS))
|
|
)
|
|
self.skipWaiting()
|
|
})
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(
|
|
caches.keys().then((keys) =>
|
|
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
|
)
|
|
)
|
|
self.clients.claim()
|
|
})
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
const url = new URL(event.request.url)
|
|
|
|
// Never cache API/auth calls
|
|
if (url.pathname.startsWith('/api/') || url.pathname.startsWith('/auth/')) {
|
|
return
|
|
}
|
|
|
|
// Navigation requests (HTML pages): always network-first
|
|
if (event.request.mode === 'navigate') {
|
|
event.respondWith(
|
|
fetch(event.request)
|
|
.then((response) => {
|
|
const clone = response.clone()
|
|
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone))
|
|
return response
|
|
})
|
|
.catch(() => caches.match(event.request).then((c) => c || caches.match('/')))
|
|
)
|
|
return
|
|
}
|
|
|
|
// Static assets (JS/CSS with content hashes): cache-first
|
|
event.respondWith(
|
|
caches.match(event.request).then((cached) => {
|
|
return cached || fetch(event.request).then((response) => {
|
|
if (event.request.method === 'GET' && response.status === 200) {
|
|
const clone = response.clone()
|
|
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone))
|
|
}
|
|
return response
|
|
})
|
|
}).catch(() => {
|
|
if (event.request.mode === 'navigate') {
|
|
return caches.match('/')
|
|
}
|
|
})
|
|
)
|
|
})
|