[object Object]

← back to Pastelwallpaper

/api/facets total counts the niche-filtered list actually served

c23bb5d55040e6a82a9674318504896fae2ca7a8 · 2026-05-19 08:04:44 -0700 · Steve Abrams

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit c23bb5d55040e6a82a9674318504896fae2ca7a8
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 19 08:04:44 2026 -0700

    /api/facets total counts the niche-filtered list actually served
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 server.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index b3ecfc1..8fc567b 100644
--- a/server.js
+++ b/server.js
@@ -134,8 +134,24 @@ 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);
+// Static-asset hardening: never serve backup/snapshot files from the static root.
+app.use((req, res, next) => {
+  if (/\.bak(\.[\w-]+)*$/i.test(req.path) || /\.pre-/i.test(req.path)) {
+    return res.status(404).send('Not found');
+  }
+  next();
+});
 app.use(express.static(path.join(__dirname, 'public')));
 
+// Clean-URL routes for extension-less nav links.
+const PAGE_FILES = ['care', 'history', 'sourcing', 'trade'];
+for (const name of PAGE_FILES) {
+  app.get('/' + name, (req, res, next) => {
+    const f = path.join(__dirname, 'public', name + '.html');
+    fs.existsSync(f) ? res.sendFile(f) : next();
+  });
+}
+
 app.get('/api/products', (req, res) => {
   const { q, aesthetic, vendor, page = 1, limit = 24, sort = 'newest'} = req.query;
   let list = PRODUCTS_NICHE;
@@ -170,7 +186,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 }));

← cf45e9e fix sort: send sort param to API + hydrate saved value befor  ·  back to Pastelwallpaper  ·  untrack 18 bak/pre snapshot files + broaden .gitignore to *. cd2c4f7 →