← back to 1900swallpaper
facets: count niche-filtered catalog + 404-guard snapshot files
f0a9d7f47784e1529cfc804294cdae83931cf5a6 · 2026-05-19 08:21:27 -0700 · SteveStudio2
/api/facets total reported PRODUCTS.length (pre-niche-filter) while
every product route serves PRODUCTS_NICHE — now reports the served
count. Added middleware that 404s any .bak/.pre- path so committed
snapshot files can never leak through the static root.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit f0a9d7f47784e1529cfc804294cdae83931cf5a6
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue May 19 08:21:27 2026 -0700
facets: count niche-filtered catalog + 404-guard snapshot files
/api/facets total reported PRODUCTS.length (pre-niche-filter) while
every product route serves PRODUCTS_NICHE — now reports the served
count. Added middleware that 404s any .bak/.pre- path so committed
snapshot files can never leak through the static root.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index 6204964..f375aab 100644
--- a/server.js
+++ b/server.js
@@ -137,6 +137,12 @@ app.use(express.json({ limit: '256kb' }));
require('./_universal-contact')(app, { siteName: "1900s Wallpaper", zdColor: "#a89060", zdPosition: 'right' });
require('./_universal-auth')(app, { siteName: "1900swallpaper" });
+// 404-guard: never serve snapshot/backup files from the static root
+app.use((req, res, next) => {
+ if (/\.(bak|pre-[^/]*)$|\.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('/api/products', (req, res) => {
@@ -173,7 +179,7 @@ app.get('/api/facets', (req, res) => {
aesthetics[p.aesthetic] = (aesthetics[p.aesthetic] || 0) + 1;
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS.length });
+ res.json({ aesthetics, vendors, total: PRODUCTS_NICHE.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← e9509eb grid: send sort param to /api/products so server-side sort i
·
back to 1900swallpaper
·
chore: untrack 29 .bak/.pre- snapshot files + broaden .gitig bf8c310 →