Skip to content

fix: resolve Node server boot crashes, missing routes, and prediction stats - #926

Open
onkar0127 wants to merge 3 commits into
Userunknown84:mainfrom
onkar0127:fix/server-startup-and-missing-files
Open

fix: resolve Node server boot crashes, missing routes, and prediction stats#926
onkar0127 wants to merge 3 commits into
Userunknown84:mainfrom
onkar0127:fix/server-startup-and-missing-files

Conversation

@onkar0127

@onkar0127 onkar0127 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

RESOLVE #836

PR Description:

Problem Summary

Following recent merges, the Node.js Express server was failing to boot and crashed immediately on startup. In addition, there were multiple missing routes and engine scripts that caused 404/500 errors on dashboard pages, along with a database query lookup bug on the /stats endpoint.

This PR cleans up Express route initialization order, stubs the missing visual routes and poisoning defense python components, aligns CLI arguments across Python detectors, and fixes database lookup models.


Key Changes

1. Core Express Initialization & Server Boot Fixes

  • File: backend/server.js
  • Reordered routes to initialize the Express app instance before mounting any middleware or custom routers, resolving the fatal ReferenceError: app is not defined.
  • Resolved a syntax error on line 48 caused by a duplicate, unclosed logStartupTime definition.
  • Cleaned up duplicate imports and route mounting for the EvoMail routes.
  • Mounted the saltingRoutes router under /api/salting.

2. Added Missing Router & Scripts

  • Files: backend/routes/visualRoutes.js, backend/llm_poisoning_defense.py
  • Created visualRoutes.js to prevent the import crash when require('./routes/visualRoutes') is resolved on server boot.
  • Created llm_poisoning_defense.py to handle command execution (--command and --params args) for the newly introduced poisoning defense endpoints (/validate, /detect, /train, /status).

3. Restructured Python CLI Support

  • Files: backend/text_salting_detector.py, backend/visual_detector.py, backend/routes/saltingRoutes.js
  • Refactored main execution hooks to parse CLI parameters cleanly when invoked by the Express child process, printing JSON outputs.
  • Fixed path extension error in saltingRoutes.js (pointing to .js instead of .py).

4. Fixed Stats Endpoint Crash

  • File: backend/routes/predictionRoutes.js
  • Replaced the undefined Prediction model in the /stats endpoint with the correct History collection lookup, and mapped userId to the correct schema parameter user.

Verification and Testing

  • Checked syntax validation on all modified JS files (node --check backend/server.js passes with zero errors).
  • Verified compilation checks on modified Python scripts (python -m py_compile passes with zero errors).
  • Ran unit tests inside the virtual environment:
    • test_crypto_utils.py (3 Passed)
    • test_sqlite_concurrency.py (1 Passed)
    • test_spam_words.py (4 Passed)

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

@onkar0127 is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@onkar0127
onkar0127 force-pushed the fix/server-startup-and-missing-files branch from 9e38f21 to 7756356 Compare July 18, 2026 17:01
@onkar0127

Copy link
Copy Markdown
Contributor Author

@Userunknown84 let me know about this PR!!

@onkar0127
onkar0127 force-pushed the fix/server-startup-and-missing-files branch from 95bc336 to 7756356 Compare July 19, 2026 05:04
Comment thread backend/controllers/emailController.js
Comment thread backend/controllers/predictionController.js
Comment thread backend/routes/analyticsRoutes.js
Comment thread backend/routes/analyticsRoutes.js
Comment thread backend/server.js
Comment thread backend/server.js

@Userunknown84 Userunknown84 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some code delete i comment on it.

…ix /trends route and restore tests configuration
Comment thread backend/routes/analyticsRoutes.js
}
});

router.get('/',protect,async(req,res) => {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This route is also delete

@Userunknown84 Userunknown84 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things i coment on it please check rest code is fine i see .

@Userunknown84 Userunknown84 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict and some code delete so kindly fix then i will merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Node.js server crashes on startup due to missing history controllers in historyRoutes

2 participants