You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A REST API that parses JavaScript source files and returns code quality metrics including lines of code, cyclomatic complexity, and maintainability index. Built with Node.js, Express, and MongoDB.
Features
JWT Authentication — register, login, and protected routes
Code Analysis — paste or upload a .js file and receive:
LOC (Lines of Code)
LLOC (Logical Lines of Code)
SLOC (Source Lines of Code)
Comment count and comment percentage
Code-to-comment ratio
Cyclomatic Complexity (via AST traversal using Esprima)
# Development (auto-restart with nodemon)
npm run dev
The server starts on http://localhost:4000.
API Endpoints
Auth
Method
Endpoint
Description
Auth Required
POST
/api/register
Create account
No
POST
/api/login
Login, receive JWT
No
GET
/api/me
Get current user
Yes
Code Analysis
Method
Endpoint
Description
POST
/api/home
Analyze a JS file
GET
/api/home
Get all analysis records
GET
/api/home/:id
Get single analysis
PATCH
/api/home/:id
Update analysis
DELETE
/api/home/:id
Delete analysis
Rules
Method
Endpoint
Description
POST
/api/
Create rule
GET
/api/
Get all rules (supports ?searchTerm=)
PUT
/api/:id
Update rule
DELETE
/api/:id
Delete rule
PUT
/api/toggleStatus/:id
Toggle active/inactive
Projects
Method
Endpoint
Description
POST
/api/projects
Create project
GET
/api/projects
Get all projects
PUT
/api/projects/:id
Update project
DELETE
/api/projects/:id
Delete project
Folders
Method
Endpoint
Description
POST
/api/folders
Create folder
GET
/api/folders
Get all folders
PUT
/api/folders/:id
Update folder
DELETE
/api/folders/:id
Delete folder
Metrics Explained
Metric
Description
LOC
Total number of lines including blanks and comments
LLOC
Lines containing a logical statement (;, {, })
SLOC
Non-blank, non-comment lines
Cyclomatic Complexity
Number of linearly independent paths; counts if, for, while, switch, catch, ternary, etc.
Maintainability Index
Score 0–100 derived from the formula 171 − 5.2·log(CC) − 0.23·SLOC − 16.2·log(SLOC). Higher is better.
About
REST API for a JavaScript static code analyzer computes LOC, cyclomatic complexity, and maintainability index via AST parsing with Esprima. Built with Node.js, Express, and MongoDB.