← back to Stars of Design
API: add /random/designer + /random/firm + /random/client redirect helpers
da27142aaba3a4e7e2019acf966aaac9fa655580 · 2026-05-13 09:32:42 -0700 · Steve Abrams
Files touched
Diff
commit da27142aaba3a4e7e2019acf966aaac9fa655580
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed May 13 09:32:42 2026 -0700
API: add /random/designer + /random/firm + /random/client redirect helpers
---
routes/public.js | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/routes/public.js b/routes/public.js
index 0655c4f..5449ebd 100644
--- a/routes/public.js
+++ b/routes/public.js
@@ -566,6 +566,33 @@ router.get('/terms', (req, res) => {
});
});
+// /random/* — 302 to a random detail page. Parity with asim /random/movie etc.
+// Falls through to the index page if the dataset is somehow empty.
+router.get('/random/designer', (_req, res) => {
+ try {
+ const all = data.load();
+ if (!all.length) return res.redirect('/designers');
+ const pick = all[Math.floor(Math.random() * all.length)];
+ res.redirect(`/designers/${pick.slug}`);
+ } catch (_e) { res.redirect('/designers'); }
+});
+router.get('/random/firm', async (_req, res) => {
+ try {
+ const rows = await firmsLib.listFirms({ limit: 1000 });
+ if (!rows.length) return res.redirect('/firms');
+ const pick = rows[Math.floor(Math.random() * rows.length)];
+ res.redirect(`/firms/${pick.slug}`);
+ } catch (_e) { res.redirect('/firms'); }
+});
+router.get('/random/client', async (_req, res) => {
+ try {
+ const rows = await clientsLib.listClients({ limit: 1000 });
+ if (!rows.length) return res.redirect('/clients');
+ const pick = rows[Math.floor(Math.random() * rows.length)];
+ res.redirect(`/clients/${pick.slug}`);
+ } catch (_e) { res.redirect('/clients'); }
+});
+
router.get('/sitemap.xml', async (req, res, next) => {
try {
const base = 'https://starsofdesign.com';
← ba5954a API: add /api/designers/random + /api/firms/random + /api/cl
·
back to Stars of Design
·
smoke: 9 new checks for /api/{designers,firms,clients}/rando 4edf44d →