1 Commits
Author SHA1 Message Date
jessikitty 8bc71792e3 Server-side printing, roll type setting, cache headers 2026-09-07 11:06:19 +10:00
3 changed files with 46 additions and 1 deletions
+1
View File
@@ -7,6 +7,7 @@
"scripts": {
"start": "node src/server.js",
"dev": "node --watch src/server.js",
"version": "node scripts/version.mjs",
"gen-secret": "node -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\""
},
"engines": {
+32
View File
@@ -0,0 +1,32 @@
// Reports what this container is actually running, so an upgrade that did not
// land can be spotted without guesswork.
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const here = path.dirname(fileURLToPath(import.meta.url));
const root = path.join(here, '..');
const FEATURES = [
['server-side printing', 'src/printer.js', null],
['roll type is a separate setting', 'src/routes/admin.js', 'printer_label'],
['roll type in the console', 'public/js/admin.js', 'printerLabel'],
['company field', 'src/routes/kiosk.js', 'company'],
['separate login page', 'public/login.html', 'step-password'],
['per-site branding', 'src/branding.js', null],
['CA in DER form for Jamf', 'src/tls.js', 'caCertificateDer'],
];
console.log('');
for (const [name, file, needle] of FEATURES) {
const full = path.join(root, file);
let state = 'MISSING';
if (fs.existsSync(full)) {
state = !needle || fs.readFileSync(full, 'utf8').includes(needle) ? 'present' : 'OLD VERSION';
}
console.log(` ${state.padEnd(12)} ${name}`);
}
console.log('');
console.log('Anything not "present" means this container is running older code.');
console.log('On the docker host: git pull && docker compose up -d --build');
console.log('');
+13 -1
View File
@@ -72,7 +72,19 @@ app.get('/admin/login', (req, res) => {
// Nobody should land on the raw filenames; keep one address per page.
app.get(['/admin.html', '/login.html'], (req, res) => res.redirect('/admin'));
app.use(express.static(publicDir, { extensions: ['html'], index: false }));
// no-cache still allows a 304 on an unchanged file, but forces the browser to ask
// first. Without it a cached admin.js survives an upgrade and the console keeps
// running yesterday's code against today's server, which is impossible to diagnose
// from the outside.
app.use(
express.static(publicDir, {
extensions: ['html'],
index: false,
setHeaders: (res, filePath) => {
if (/\.(html|js|css)$/.test(filePath)) res.setHeader('Cache-Control', 'no-cache');
},
})
);
app.get('/favicon.ico', (req, res) => res.redirect(301, '/favicon.svg'));
app.use((req, res) => res.status(404).sendFile(path.join(publicDir, 'index.html')));