Skip to content

komad1na/virus-scan-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virus Scanning API

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.

Features

File Scanning

  • 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 Management

  • User registration and authentication
  • Secure password hashing with bcrypt
  • User profile management
  • JWT-based authentication

Report Management

  • Generate comprehensive scan reports
  • Store and retrieve scan history
  • Track scanning statistics
  • Export report data

Security Features

  • Secure file handling with sanitization
  • Rate limiting: 100 requests per hour per IP
  • Password hashing using bcrypt
  • JWT token-based authentication

API Endpoints

File Scanning

  • 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)
  • 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)
  • 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)

User Management

  • 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)
  • 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)
  • 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)
  • 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)
  • DELETE /api/v1/users/:id - Delete user

    • Parameters: id (string) - User ID
    • Response: { message: string }
    • Status Codes: 200 (Success), 404 (Not Found)

Error Handling

  • Proper HTTP status codes (200, 201, 400, 404, 413)
  • Descriptive error messages
  • File validation handling
  • Database error handling
  • Authentication error handling

Testing

The application includes comprehensive test coverage using Jest, testing:

  • User authentication and management
  • File scanning functionality
  • Report generation and retrieval
  • Error scenarios
  • File validation

Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Jest (Testing)
  • bcrypt (Password Hashing)
  • JWT (Authentication)

Getting Started

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Set up environment variables
  4. Run the development server:
    npm run dev
  5. Run tests:
    npm test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors