PWA Phase 1: manifest, service worker, icons, and static serving

Adds manifest.json, sw.js (static-only caching, never admin routes),
placeholder cyan T icons (192 + 512), express.static middleware, and
PWA meta tags + service worker registration in layout.ejs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (Chronicler #83 - The Compiler)
2026-04-14 11:32:35 -05:00
parent b1d8dde4bf
commit 1bee838c8d
6 changed files with 64 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ const DiscordStrategy = require('passport-discord').Strategy;
const { Client, GatewayIntentBits, REST, Routes } = require('discord.js');
const csrf = require('csurf');
const cors = require('cors');
const path = require('path');
const { Pool } = require('pg');
const authRoutes = require('./routes/auth');
@@ -74,6 +75,9 @@ app.use((req, res, next) => {
// Mounted at /webhooks/stripe to avoid conflict with /stripe checkout mount
app.use('/webhooks/stripe', stripeRoutes);
// Static files (PWA manifest, icons, service worker)
app.use(express.static(path.join(__dirname, 'public')));
// Body parsing middleware (comes AFTER webhook route)
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -0,0 +1,24 @@
{
"name": "Trinity Console",
"short_name": "Trinity",
"description": "Firefrost Gaming Operations Console",
"start_url": "/admin",
"display": "standalone",
"background_color": "#1a1a1a",
"theme_color": "#06b6d4",
"orientation": "portrait-primary",
"icons": [
{
"src": "/images/trinity-icon-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/images/trinity-icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
]
}

View File

@@ -0,0 +1,21 @@
const CACHE_NAME = 'trinity-console-v1';
const STATIC_ASSETS = [
'/css/app.css',
'/manifest.json'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(STATIC_ASSETS))
);
});
self.addEventListener('fetch', event => {
// Only cache GET requests for static assets
if (event.request.method !== 'GET') return;
if (event.request.url.includes('/admin/')) return; // Never cache admin routes
event.respondWith(
caches.match(event.request).then(cached => cached || fetch(event.request))
);
});

View File

@@ -4,6 +4,21 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= title %> | Trinity Console</title>
<!-- PWA -->
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#06b6d4">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Trinity">
<link rel="apple-touch-icon" href="/images/trinity-icon-192.png">
<!-- Service Worker Registration -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch(err => console.log('SW registration failed:', err));
});
}
</script>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/htmx.org@1.9.11"></script>
<script>