← All Projects
Legacy Node.js API Modernization
Node.jsTypeScriptMongoDBMongooseHerokuGulp

Legacy Node.js API Modernization

Overview

I worked on modernizing two APIs that had been running on Node.js 10: a mobile API upgraded to Node.js 20 and a lead-generation API upgraded to Node.js 16.

Although both projects started with the same underlying problem, they required different approaches. The mobile API involved a broader runtime and TypeScript modernization across a large codebase. The lead-generation API required a more incremental migration strategy that accounted for compatibility constraints, legacy build tooling, and deployment behavior.

Project 1: Mobile API Modernization

Node.js 10 to 20 | TypeScript 2.6 to 5.9

The challenge

The mobile API was running on an outdated Node.js runtime and an older TypeScript toolchain. Modernizing the runtime meant addressing compatibility issues throughout the codebase, including changes in language tooling and deprecated Mongoose APIs. This wasn't a simple runtime configuration change: it required coordinated changes across a substantial number of files while maintaining compatibility with the existing application.

The approach

  • Runtime modernization: Upgraded Node.js from 10 to 20.
  • TypeScript modernization: Upgraded TypeScript from 2.6 to 5.9 and handled the resulting codebase compatibility changes.
  • Large-scale refactoring: Updated approximately 160 files and converted approximately 1,000 imports as part of the migration.
  • Database compatibility: Addressed Mongoose deprecations introduced by the modernization effort.
  • Legacy integration constraints: Some modern SDKs weren't viable within the old runtime, which made direct HTTPS integration the more practical choice for external API communication.

Project 2: Lead Generation API Modernization

Node.js 10 to 16 | Heroku

The challenge

Roughly eight months earlier, a different engineer had attempted a direct jump from Node 10 to Node 18 alongside a MongoDB 7 upgrade, which stalled under the weight of too many simultaneous changes and left our CTO wary of another attempt. Staying on Node 10 was a growing security liability, though, and it was quietly blocking the team from adopting the modern AI tooling everyone wanted to use. I pushed to try again with a different approach: a staged migration from 10 to 14 to 16 to 18 to 20+, with each phase independently revertable, its own documented test surface, and a decisions ledger recording the reasoning behind every call, so a bad step could be rolled back on its own instead of threatening the whole effort.

The approach

Phase 1 targeted Node 14 as a low-risk first hop. It hit an Apple Silicon compatibility issue partway through, so I adapted the plan and jumped from 10 straight to 16, skipping 14 entirely. I deliberately deferred the crypto migration (Node 17 removed createCipher/createDecipher outright) and a sweep of 16 new Buffer() call sites to a later 16-to-18 phase, since neither was required to reach 16 safely. Node 18, and eventually 20+, remained the intended next destinations, but I left the role before that work was tasked.

  • Build pipeline debugging: Traced a Gulp build hang to a missing callback in an asynchronous series.
  • Dependency conflict prevention: Identified a latent Lodash version collision before it reached production.
  • Deployment troubleshooting: Addressed two Heroku-specific issues affecting the deployment workflow.
  • Production verification: Used Heroku Review Apps to validate the application end to end.

What This Demonstrates

  • Incremental modernization: Choosing migration boundaries based on actual compatibility constraints, not pursuing every upgrade simultaneously.
  • Root-cause analysis: Investigating the actual causes of build and dependency failures instead of applying superficial fixes.
  • Production verification: Validating deployed behavior under production-like conditions, not just that it compiled.