From b540b34ee9dc48a8f140e7e25a3897aa17f06413 Mon Sep 17 00:00:00 2001 From: you Date: Tue, 24 Mar 2026 02:42:47 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20export=20cache,=20pktStore,=20db=20from?= =?UTF-8?q?=20server.js=20=E2=80=94=20needed=20by=20route=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-server-routes.js destructures { cache, pktStore, db } but these weren't in module.exports. Also adds require.main guard so server doesn't listen when imported by tests. --- server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index bc3ec9f9..c2ae09b4 100644 --- a/server.js +++ b/server.js @@ -2912,6 +2912,7 @@ app.get('/{*splat}', (req, res) => { // --- Start --- const listenPort = process.env.PORT || config.port; +if (require.main === module) { server.listen(listenPort, () => { const protocol = isHttps ? 'https' : 'http'; console.log(`MeshCore Analyzer running on ${protocol}://localhost:${listenPort}`); @@ -2959,6 +2960,7 @@ server.listen(listenPort, () => { warmNext(); }, 5000); // 5s delay — let initial client page load complete first }); +} // end if (require.main === module) // --- Graceful Shutdown --- let _shuttingDown = false; @@ -2998,4 +3000,4 @@ function shutdown(signal) { process.on('SIGTERM', () => shutdown('SIGTERM')); process.on('SIGINT', () => shutdown('SIGINT')); -module.exports = { app, server, wss }; +module.exports = { app, server, wss, pktStore, db, cache };