← back to Wallpaperdefinitions

server.js

21 lines

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

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

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

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

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

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