← back to Screenprintedwallpaper
wire api-vendor-redact middleware + /api/facets respects current filters
bc239fa27b5941060e9ca57b9e1357d5085075d1 · 2026-05-25 21:30:13 -0700 · Steve Abrams
Files touched
Diff
commit bc239fa27b5941060e9ca57b9e1357d5085075d1
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon May 25 21:30:13 2026 -0700
wire api-vendor-redact middleware + /api/facets respects current filters
---
server.js | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index 65126bc..493c5a5 100644
--- a/server.js
+++ b/server.js
@@ -52,6 +52,11 @@ let PRODUCTS_NICHE = [];
const app = express();
+// Fleet-wide standing rule: strip vendor field + vendors facet from /api/* JSON
+// (Steve directive "DW vendor names NEVER in customer-facing UI"). MUST mount
+// before any /api/* route registration so the res.json wrapper catches them.
+try { app.use(require('../_shared/api-vendor-redact')); }
+catch (e) { console.error(`[${__SITE}] api-vendor-redact unavailable (${e.message}) — continuing without it`); }
app.use(express.json({ limit: "256kb" }));
// Site config — prefer _shared/site-config (canonical) but fall back to an
// inline minimal loader so this server.js is self-contained on Kamatera.
@@ -153,12 +158,23 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ // Counts reflect the CURRENT filtered list (same q/aesthetic/vendor pipeline
+ // as /api/products) so the facet rail tells the user "if you also apply X,
+ // here's what's left" instead of always showing the full-catalog count.
+ const { q, aesthetic, vendor } = req.query;
+ let list = PRODUCTS_NICHE;
+ if (q) {
+ const needle = String(q).toLowerCase();
+ list = list.filter(p => (p.title || '').toLowerCase().includes(needle) || (p.tags || []).some(t => t.toLowerCase().includes(needle)));
+ }
+ if (aesthetic && aesthetic !== 'all') list = list.filter(p => p.aesthetic === aesthetic);
+ if (vendor && vendor !== 'all') list = list.filter(p => p.vendor === vendor);
const aesthetics = {}; const vendors = {};
- for (const p of PRODUCTS_NICHE) {
+ for (const p of list) {
aesthetics[p.aesthetic] = (aesthetics[p.aesthetic] || 0) + 1;
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS_NICHE.length });
+ res.json({ aesthetics, vendors, total: list.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← 55692ef pull-from-shopify: use shared classifier with rails primary,
·
back to Screenprintedwallpaper
·
add rel=noopener noreferrer on target=_blank (FB link + sist cb1b230 →