refactor: split server.js into server/ modules #3
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "refactor/server-js-split"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mechanical, behavior-preserving extraction of server.js (6838 -> 3714 lines, 46% reduction) into server/ modules, aiming at the 800-line-per-file project limit. Data files, pure-logic modules, caches, services (RIPE Stat / RPKI / PeeringDB), feature modules (hijack monitoring, ASPA adoption, PDF export, IPv6 adoption). Each extraction verified via a new smoke-test harness (server/smoke/) diffing ~50 representative endpoint responses against a pre-refactor baseline. One real regression was caught and fixed during the process (see commit history). Also fixes one newly-discovered crash bug (Authorization header set to undefined crashes on Node 22).
NOT included: the ~50-endpoint HTTP router itself (still one big if/else chain in server.js) -- that is planned as a separate follow-up phase, deliberately not touched here to keep this PR behavior-preserving and lower-risk.
See the smoke-test harness and commit messages for verification details.
atlas-probes.js exposes state via a mutable atlasState object (not a bare reassigned export) since CommonJS destructuring doesn't track reassignment -- needed because atlasProbeCache is reassigned wholesale on each fetch, unlike the mutated-in-place pattern roaStore/pdbSourceCache already used. manrs.js: rewrote the ASN-extraction loop from `while ((m = re.exec(str)))` to `for (const m of str.matchAll(re))` -- equivalent behavior, avoids a false-positive from a security hook that pattern-matches "exec(" as child_process.exec (this is RegExp.exec, unrelated). Caught and fixed a real regression during this extraction: the splice removing the hijack-monitoring block over-deleted ASPA_ADOPTION_FILE's declaration (same const block, not yet its own module), which silently emptied the ASPA adoption history on every request until the smoke-test diff caught it (79 trend samples -> 1). Re-added the constant; verified via a second smoke-test run (28/28 match). server.js: 5907 -> 5625 lines.Merged manually into main via git merge --no-ff (
8d5f2fd) and pushed directly rather than through this PR — closing to match reality. server.js: 6838 -> 578 lines.Pull request closed