Express + SQLite (node:sqlite, no native build step) family calendar: parent accounts with household invites, per-child calendars with save/duplicate/print, a token-gated read-only kiosk view for tablets, and polling to keep parent and kiosk views in sync. Defaults to port 3007.
16 lines
496 B
JavaScript
16 lines
496 B
JavaScript
const db = require('../db');
|
|
|
|
const getChildByTokenStmt = db.prepare('SELECT * FROM children WHERE kiosk_token = ?');
|
|
|
|
function resolveKiosk(req, res, next) {
|
|
if (typeof req.params.token !== 'string' || !req.params.token) {
|
|
return res.status(404).json({ error: 'Invalid kiosk link' });
|
|
}
|
|
const child = getChildByTokenStmt.get(req.params.token);
|
|
if (!child) return res.status(404).json({ error: 'Invalid kiosk link' });
|
|
req.child = child;
|
|
next();
|
|
}
|
|
|
|
module.exports = resolveKiosk;
|