← back to Wallpaperhistory

server.js

23 lines

const express = require('express');
const path = require('path');
const app = express();
const PORT = process.env.PORT || 9903;

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

app.use(express.static(path.join(__dirname, 'public')));

app.get('/health', (req, res) => res.json({ status: 'ok', site: 'wallpaperhistory.com' }));

app.get('/', (req, res) => {
  res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

app.listen(PORT, () => console.log(`wallpaperhistory.com :${PORT}`));