fix: export cache, pktStore, db from server.js — needed by route tests

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.
This commit is contained in:
you
2026-03-24 02:42:47 +00:00
parent 0b1f7aaead
commit b540b34ee9
+3 -1
View File
@@ -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 };