DEV Community

apexautomationlabs
apexautomationlabs

Posted on

Building a 58 MB RAM Domain Intelligence API in Pure Node.js: DNS-over-HTTPS Fallback, RDAP Bootstrap, TLS Sockets & Zero Browsers

Most domain enrichment and email deliverability APIs have two classic problems: they either spin up headless browsers just to fingerprint a homepage tech stack, or they rely on port-25 SMTP probes that time out inside cloud containers. Even worse, standard dns.resolveTxt() calls in Docker containers silently drop truncated UDP responses on enterprise domains with 25–50 TXT verification records (stripe.com, github.com, linear.app).

Here is how we solved all three in pure Node.js 22 + TypeScript at $2.00 / 1,000 domains ($0 start fee):

  1. Container-Safe DNS + DoH TXT Fallback: Query A, AAAA, MX, NS, TXT, and _dmarc via node:dns/promises with strict timeouts—and whenever a live domain returns empty/timed-out TXT records due to UDP truncation, automatically fall back to Google DNS-over-HTTPS (dns.google/resolve).
  2. Email Provider, Gateway & Auth Readiness Score (0–100): Classify Google Workspace, Microsoft 365, Zoho, Proton, Fastmail, Proofpoint, and Mimecast, estimate SPF DNS lookup counts (catching RFC 7208 >10 lookup limits), parse DMARC p=/sp=/rua=, and grade outbound readiness A–F.
  3. IANA RDAP Bootstrap + Live node:tls Inspection: Cache data.iana.org/rdap/dns.json in memory with graceful fallback when a TLD lacks RDAP, and inspect live port-443 certificates with rejectUnauthorized: false so expired certs still report daysUntilExpiry and authorizationError instead of crashing.
  4. Bounded 256 KB HTTP/Tech Stack Fingerprinting: Manually trace redirects (redirect: 'manual'), cap response body reads at 256 KB via ReadableStream reader, and fingerprint CDNs/WAFs, frameworks, HSTS/CSP/X-Frame-Options, robots.txt, and sitemap.xml.

Verified Live Apify Cloud Benchmark (128 MB RAM)

  • 5 diverse domains (stripe.com, linear.app, github.com, shopify.com, plus an unresolvable .invalid domain)
  • Total Container Duration: 4.44s (2.45s analysis time)
  • Peak Memory: 58.5 MB (avg 44.9 MB)
  • Compute Units: 0.0001542 CU (~0.031 CU / 1,000 domains)

Try It via Apify Store, MCP, or n8n

Top comments (0)