← back to Nationalrealestate
usre /api/brokers: default to affiliated-only (agent must have a firm/broker); ?unaffiliated=1 opts into full registry
5ddf9204fb974d62bf5487a95da20f7d69e2291b · 2026-08-12 14:01:42 -0700 · Steve Abrams
Drops ~174k standalone/NBA CA licensees so the RENTV desk + directory show real
practicing brokers, not the full DRE list. Filters at SQL source so total/paging/counts self-correct.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 5ddf9204fb974d62bf5487a95da20f7d69e2291b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Aug 12 14:01:42 2026 -0700
usre /api/brokers: default to affiliated-only (agent must have a firm/broker); ?unaffiliated=1 opts into full registry
Drops ~174k standalone/NBA CA licensees so the RENTV desk + directory show real
practicing brokers, not the full DRE list. Filters at SQL source so total/paging/counts self-correct.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
src/server/index.ts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/server/index.ts b/src/server/index.ts
index 5137d8a..c34cc7f 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -376,6 +376,12 @@ app.get('/api/brokers', async (req, res) => {
if (s === 'active') { conds.push(`b.license_status ILIKE 'active%'`); }
else { params.push(s); conds.push(`lower(b.license_status) = $${params.length}`); }
}
+ // An agent only appears if it's associated with a broker/firm (has an employing
+ // firm_id). Drops standalone DRE licensees — incl. "Licensed NBA" (No Broker
+ // Affiliation) — so this returns real practicing brokers, not the full DRE list.
+ // Default ON for every consumer (desk, directory, etc.); ?unaffiliated=1 opts back
+ // into the full registry.
+ if (String(req.query.unaffiliated || '') !== '1') { conds.push(`b.firm_id IS NOT NULL`); }
const where = conds.length ? 'WHERE ' + conds.join(' AND ') : '';
params.push(limit, offset);
const r = await query(
← be069fc usre: pm2 ecosystem runs 'node --import tsx' directly (orpha
·
back to Nationalrealestate
·
usre /api/brokers: return broker_email + firm-level phone/em 986b8c8 →