A Node.js REST API for managing users, projects, tasks, and comments.
- User registration and login with JWT authentication
- Project creation and membership-based access
- Task creation and pagination inside projects
- Commenting on tasks with access control
- Centralized error handling and consistent JSON response format
- Swagger documentation available at
/api-docs
- Node.js 24+ installed
- MongoDB database connection string
npm installCreate a .env file in the project root using the example below:
cp .env.example .envThen set the values:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secretnpm run devOr start production mode:
npm startDetailed endpoint documentation is available in docs/API.md.
The project exposes Swagger UI at:
http://localhost:5000/api-docs
Successful responses use this structure:
{
"success": true,
"data": { ... }
}Error responses use this structure:
{
"success": false,
"statusCode": 400,
"message": "Error message",
"errors": [ ... ]
}A simple endpoint test script is available:
node test-endpoints.jsThis script exercises the full flow:
- Register user
- Login
- Create project
- List projects
- Create task
- List tasks with pagination
- Add comment
-
The API uses JWT bearer authentication for protected routes.
-
Protected routes:
POST /api/projectsGET /api/projectsPOST /api/tasks/:projectIdGET /api/tasks/:projectIdPOST /api/comments/:taskId
-
The Swagger spec is generated from route JSDoc comments.
-
Make sure
logs/and.envare not committed to GitHub.