← back to Wallpaperestimator

server.js

38 lines

/**
 * Wallpaper Estimator — pure client-side yardage calculator.
 *
 * The calculator runs entirely in the browser. The server is a thin
 * Express static-file host so the project fits the pm2 + nginx pattern
 * the rest of the DW fleet uses.
 */
const express = require('express');
const helmet = require('helmet');
const path = require('path');

const PORT = process.env.PORT || 9933;
const SITE = 'wallpaperestimator';

const app = express();
app.use(helmet({ contentSecurityPolicy: false }));

app.use((req, res, next) => {
  res.setHeader('Cache-Control', 'no-store, must-revalidate');
  next();
});

// 404-guard: never serve snapshot/backup files from the static root.
app.use((req, res, next) => {
  if (/\.(bak|orig|swp|tmp)$|\.bak\.|\.pre-/i.test(req.path)) {
    return res.status(404).send('Not found');
  }
  next();
});

app.use(express.static(path.join(__dirname, 'public'), { extensions: ['html'] }));

app.get('/healthz', (_req, res) => res.json({ ok: true, site: SITE, port: PORT }));

app.listen(PORT, '0.0.0.0', () => {
  console.log(`[${SITE}] listening on :${PORT}`);
});