← back to Wallco Ai
wallco.ai · /api/designs/by-color now accepts optional ?within=category to restrict color-neighbors to a single category (e.g. 'more in this palette WITHIN damask'). Response echoes within for client confirmation. Verified hex=%23c16d74 unfiltered → 228 candidates (top floral/mixed/mixed) · within=floral → 17 candidates (all floral) · within=damask → 174 candidates (all damask)
7cddfa68a7cb554ecfd6994b0bfddb4394c63bcb · 2026-05-12 10:36:59 -0700 · SteveStudio2
Files touched
Diff
commit 7cddfa68a7cb554ecfd6994b0bfddb4394c63bcb
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date: Tue May 12 10:36:59 2026 -0700
wallco.ai · /api/designs/by-color now accepts optional ?within=category to restrict color-neighbors to a single category (e.g. 'more in this palette WITHIN damask'). Response echoes within for client confirmation. Verified hex=%23c16d74 unfiltered → 228 candidates (top floral/mixed/mixed) · within=floral → 17 candidates (all floral) · within=damask → 174 candidates (all damask)
---
server.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index 020bc6b..0bd7f62 100644
--- a/server.js
+++ b/server.js
@@ -385,19 +385,23 @@ app.get('/api/designs/by-color', (req, res) => {
const hex = String(req.query.hex || '').trim();
const n = Math.max(1, Math.min(50, parseInt(req.query.n || '12', 10)));
const exclude = new Set(String(req.query.exclude || '').split(',').map(s => parseInt(s.trim(),10)).filter(x => x>0));
+ // Optional ?within=category — restricts results to designs in this category.
+ // Useful for "more in this palette WITHIN damask" rails on a vertical PDP.
+ const within = String(req.query.within || '').toLowerCase().trim();
const target = _hexToLab(hex);
if (!target) return res.status(400).json({ ok:false, error:'invalid hex (try ?hex=%23c16d74 or hex=c16d74)' });
const ranked = [];
for (const d of DESIGNS) {
if (exclude.has(d.id)) continue;
if (!d.dominant_hex) continue;
+ if (within && (d.category || '').toLowerCase() !== within) continue;
const lab = _hexToLab(d.dominant_hex);
if (!lab) continue;
ranked.push({ id: d.id, title: d.title, category: d.category, handle: d.handle, image_url: d.image_url, dominant_hex: d.dominant_hex, room_mockups: d.room_mockups || [], delta_e: _dE(target, lab), url: `/design/${d.id}` });
}
ranked.sort((a,b) => a.delta_e - b.delta_e);
res.setHeader('Cache-Control', 'public, max-age=300, must-revalidate');
- res.json({ hex, n, count: ranked.length, exclude: [...exclude], results: ranked.slice(0, n).map(r => ({ ...r, delta_e: Math.round(r.delta_e * 10)/10 })) });
+ res.json({ hex, n, within: within || null, count: ranked.length, exclude: [...exclude], results: ranked.slice(0, n).map(r => ({ ...r, delta_e: Math.round(r.delta_e * 10)/10 })) });
});
// ── /api/designs/random?n=12&category=floral&seed=42
← 869d5a0 wallco.ai · PDP wall-calculator persists last-used W×H to lo
·
back to Wallco Ai
·
wallco.ai · /compare gets ?view=grid image-comparison mode ( 84478a0 →