A RESTful API for virus scanning built with Node.js, Express, and MongoDB. This API provides secure file scanning capabilities along with user authentication and management features.
- Real-time virus detection
- Multiple file format support (.pdf, .doc, .docx, .txt)
- Detailed threat analysis
- Scan history tracking
- File size limit: 10MB per file
- User registration and authentication
- Secure password hashing with bcrypt
- User profile management
- JWT-based authentication
- Generate comprehensive scan reports
- Store and retrieve scan history
- Track scanning statistics
- Export report data
- Secure file handling with sanitization
- Rate limiting: 100 requests per hour per IP
- Password hashing using bcrypt
- JWT token-based authentication
-
POST /api/v1/scan- Scan a file for viruses- Request Body:
{ file: File } - Response:
{ reportId: string, status: string, timestamp: Date } - Status Codes: 200 (Success), 400 (Invalid file), 413 (File too large)
- Request Body:
-
GET /api/v1/reports/:id- Get virus scan report by ID- Parameters:
id(string) - Report ID - Response:
{ id: string, status: string, threats: Array, timestamp: Date } - Status Codes: 200 (Success), 404 (Report not found)
- Parameters:
-
GET /api/v1/reports- List all virus scan reports- Query Parameters:
page(number, default: 1)limit(number, default: 10)
- Response:
{ reports: Array, total: number, page: number } - Status Codes: 200 (Success)
- Query Parameters:
-
POST /api/v1/users/register- Register a new user- Request Body:
{ firstName: string, lastName: string, email: string, password: string } - Response:
{ message: string } - Status Codes: 201 (Created), 400 (Validation Error)
- Request Body:
-
POST /api/v1/users/login- User login- Request Body:
{ email: string, password: string } - Response:
{ token: string, user: Object } - Status Codes: 200 (Success), 400 (Invalid Credentials)
- Request Body:
-
GET /api/v1/users/:id- Get user by ID- Parameters:
id(string) - User ID - Response:
{ user: Object, usage: Object } - Status Codes: 200 (Success), 404 (Not Found)
- Parameters:
-
PUT /api/v1/users/:id- Update user- Parameters:
id(string) - User ID - Request Body:
{ firstName?: string, lastName?: string, email?: string } - Response:
{ user: Object } - Status Codes: 200 (Success), 404 (Not Found), 400 (Validation Error)
- Parameters:
-
DELETE /api/v1/users/:id- Delete user- Parameters:
id(string) - User ID - Response:
{ message: string } - Status Codes: 200 (Success), 404 (Not Found)
- Parameters:
- Proper HTTP status codes (200, 201, 400, 404, 413)
- Descriptive error messages
- File validation handling
- Database error handling
- Authentication error handling
The application includes comprehensive test coverage using Jest, testing:
- User authentication and management
- File scanning functionality
- Report generation and retrieval
- Error scenarios
- File validation
- Node.js
- Express.js
- MongoDB
- Jest (Testing)
- bcrypt (Password Hashing)
- JWT (Authentication)
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables
- Run the development server:
npm run dev
- Run tests:
npm test