Skip to content

CocoonWorks/api-load-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Testing Dashboard

A comprehensive Node.js web application for testing different API endpoints with various parameters and getting detailed responses. Built with Express.js and EJS templating engine.

Features

  • Multiple HTTP Methods: Support for GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS
  • Dynamic Headers: Add custom headers for authentication, content-type, etc.
  • Query Parameters: Test endpoints with various query string parameters
  • Request Body: Support for JSON, form-data, XML, and plain text
  • Response Analysis: View response body, headers, and request information
  • Performance Metrics: Response time tracking and status codes
  • Request History: Save and view previous API calls
  • Export Options: Copy responses and download results
  • Responsive Design: Works on desktop and mobile devices
  • Security Features: Rate limiting, CORS, and security headers

Installation

  1. Clone or download the project files

  2. Install dependencies:

    npm install
  3. Start the application:

    # Development mode with auto-reload
    npm run dev
    
    # Production mode
    npm start
  4. Open your browser and navigate to:

    http://localhost:3000
    

Project Structure

api-testing-dashboard/
├── server.js              # Main Express server
├── package.json           # Dependencies and scripts
├── views/
│   └── dashboard.ejs      # Main dashboard template
├── public/
│   ├── css/
│   │   └── style.css      # Dashboard styling
│   └── js/
│       └── dashboard.js   # Frontend functionality
└── README.md              # This file

Usage

Basic API Testing

  1. Select HTTP Method: Choose from GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS
  2. Enter URL: Provide the complete API endpoint URL
  3. Set Timeout: Configure request timeout (default: 30 seconds)
  4. Add Headers: Include custom headers like Authorization, Content-Type, etc.
  5. Query Parameters: Add URL query parameters if needed
  6. Request Body: For POST/PUT requests, enter the request body content
  7. Send Request: Click "Send Request" to test the API

Advanced Features

  • Headers Management: Add/remove custom headers dynamically
  • Parameter Testing: Test with various query parameters
  • Content Types: Support for JSON, form-data, XML, and plain text
  • Response Analysis: View response in multiple tabs (Body, Headers, Request Info)
  • Export Options: Copy responses to clipboard or download as files
  • Request History: Automatically saves all API calls for reference

Example API Tests

GET Request

Method: GET
URL: https://jsonplaceholder.typicode.com/posts/1
Headers: Accept: application/json

POST Request

Method: POST
URL: https://jsonplaceholder.typicode.com/posts
Headers: Content-Type: application/json
Body: {"title": "Test Post", "body": "This is a test", "userId": 1}

Authentication Example

Method: GET
URL: https://api.github.com/user
Headers: Authorization: Bearer YOUR_TOKEN

Configuration

Environment Variables

Create a .env file in the root directory:

PORT=3000
NODE_ENV=development

Customization

  • Port: Change the default port in server.js or via environment variable
  • Rate Limiting: Modify rate limit settings in server.js
  • CORS: Adjust CORS settings for your deployment environment
  • Security Headers: Customize Helmet.js security settings

API Endpoints

Dashboard

  • GET / - Main dashboard interface

Testing API

  • POST /api/test - Execute API requests
  • GET /api/history - Get request history (placeholder)

Security Features

  • Helmet.js: Security headers for protection against common vulnerabilities
  • Rate Limiting: Prevents abuse with configurable request limits
  • CORS: Configurable Cross-Origin Resource Sharing
  • Input Validation: Server-side validation of all inputs
  • Error Handling: Comprehensive error handling and logging

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

Troubleshooting

Common Issues

  1. Port already in use: Change the PORT in .env or kill the process using the port
  2. CORS errors: Ensure your target API allows requests from your domain
  3. Timeout errors: Increase the timeout value for slow APIs
  4. JSON parsing errors: Verify your request body is valid JSON

Debug Mode

Enable debug logging by setting:

NODE_ENV=development npm run dev

Development

Adding New Features

  1. Frontend: Modify views/dashboard.ejs and public/js/dashboard.js
  2. Backend: Extend server.js with new routes and functionality
  3. Styling: Update public/css/style.css for UI changes

Testing

Run the test suite:

npm test

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Support

For issues and questions:

  1. Check the troubleshooting section
  2. Review the code comments
  3. Open an issue on the repository

Happy API Testing! 🚀

About

Nodejs application to test api load

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published