← back to Recycledwallpaper
Add .bak/.pre- 404-guard, clean-URL nav routes, explicit facets total
70cfb8b368f9c4b01c304d91af9e67afea85bbc0 · 2026-05-19 07:55:39 -0700 · Steve Abrams
- Express middleware 404s any .bak/.pre-/.orig/.swp path before static.
- Clean-URL routes: /about /history /care /sourcing /trade /vocabulary.
- /api/facets total derived from the served PRODUCTS list explicitly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 70cfb8b368f9c4b01c304d91af9e67afea85bbc0
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue May 19 07:55:39 2026 -0700
Add .bak/.pre- 404-guard, clean-URL nav routes, explicit facets total
- Express middleware 404s any .bak/.pre-/.orig/.swp path before static.
- Clean-URL routes: /about /history /care /sourcing /trade /vocabulary.
- /api/facets total derived from the served PRODUCTS list explicitly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server.js | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index d7662a8..933461c 100644
--- a/server.js
+++ b/server.js
@@ -118,6 +118,25 @@ app.use(express.json({ limit: "256kb" }));
const cfg = require('../_shared/site-config').load(__dirname);
require("./_universal-contact")(app, cfg.contact);
require("./_universal-auth")(app, cfg.auth);
+// Never serve editor snapshots from static root.
+app.use((req, res, next) => {
+ if (/\.(bak|pre-[^/]*|orig|swp)(\.|$)|\.bak$|\.pre-/i.test(req.path)) {
+ return res.status(404).send('Not found');
+ }
+ next();
+});
+// Clean-URL routes for extension-less nav links → existing static pages.
+const CLEAN_URLS = {
+ '/about': 'history.html',
+ '/history': 'history.html',
+ '/care': 'care.html',
+ '/sourcing': 'sourcing.html',
+ '/trade': 'trade.html',
+ '/vocabulary': 'vocabulary.html',
+};
+for (const [route, file] of Object.entries(CLEAN_URLS)) {
+ app.get(route, (req, res) => res.sendFile(path.join(__dirname, 'public', file)));
+}
app.use(express.static(path.join(__dirname, 'public')));
app.get('/api/products', (req, res) => {
@@ -150,11 +169,14 @@ app.get('/api/sliders', (req, res) => {
app.get('/api/facets', (req, res) => {
const aesthetics = {}; const vendors = {};
+ // total reflects the FILTERED/niche list actually served by /api/products.
+ let total = 0;
for (const p of PRODUCTS) {
+ total++;
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 });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS.length, dropped: DROPPED }));
← 7403b57 hero-4grid: relocate json from data/ to public/ for Express
·
back to Recycledwallpaper
·
Wire sort select to API: hydrate from localStorage before fi e5f25ed →