Thank you for your interest in contributing to the Node-Go Reverse Proxy project! This document provides guidelines and suggestions for contributing.
When filing bug reports, please include:
- Clear description of the issue
- Steps to reproduce the problem
- Expected behavior vs actual behavior
- Environment details (Node.js version, OS, etc.)
- Code examples that demonstrate the issue
For feature requests, please:
- Search existing issues first to avoid duplicates
- Describe the use case and why it would be valuable
- Provide examples of how the feature would be used
- Consider backward compatibility implications
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following our coding standards
- Add tests for new functionality
- Update documentation if needed
- Commit with clear messages
- Push to your fork (
git push origin feature/amazing-feature) - Open a Pull Request
- Node.js 16+ and npm
- Go 1.19+ (for testing with Go services)
- Git
# Clone your fork
git clone https://github.com/your-username/node-go-proxy.git
cd node-go-proxy
# Install dependencies
npm install
# Run tests
npm test
# Start example Go server for testing
cd examples && go run server.go- Use TypeScript for all new code
- Follow ESLint and Prettier configurations
- Use meaningful variable names
- Add JSDoc comments for public functions
- Prefer async/await over Promises
/**
* Proxies HTTP requests to a target server
* @param options - Proxy configuration options
* @param callback - Optional callback for request/response processing
*/
export const expressMiddlewareProxy = (
options: ProxyOptions,
callback?: ProxyCallback
) => {
// Implementation
};- Write unit tests for all new functions
- Write integration tests for middleware behavior
- Use Jest for testing framework
- Aim for 80%+ test coverage
describe('expressMiddlewareProxy', () => {
it('should proxy GET requests correctly', async () => {
// Test implementation
});
it('should handle file uploads', async () => {
// Test implementation
});
});When adding features, update the README with:
- Usage examples
- API documentation
- Configuration options
- Use JSDoc for function documentation
- Add inline comments for complex logic
- Explain why, not just what
- Avoid memory leaks in long-running processes
- Stream large responses when possible
- Implement size limits for request/response data
- Handle all error cases gracefully
- Provide meaningful error messages
- Log errors appropriately
try {
await processRequest();
} catch (error) {
console.error('Request processing failed:', error.message);
res.status(500).json({ error: 'Internal server error' });
}We follow Semantic Versioning:
- Patch (1.0.x): Bug fixes
- Minor (1.x.0): New features (backward compatible)
- Major (x.0.0): Breaking changes
Update CHANGELOG.md with:
- Added features
- Changed behavior
- Deprecated functionality
- Removed features
- Fixed bugs
- Security improvements
- Unit Tests: Test individual functions
- Integration Tests: Test middleware with Express
- End-to-End Tests: Test with real Go services
describe('Feature Name', () => {
beforeEach(() => {
// Setup
});
afterEach(() => {
// Cleanup
});
describe('when condition', () => {
it('should behave correctly', () => {
// Test
});
});
});Problem: Writing to response stream multiple times
Solution: Buffer data first, then write once
// ❌ Wrong
pres.on('data', chunk => {
chunks.push(chunk);
ores.write(chunk); // Don't do this with callbacks
});
// ✅ Correct
pres.on('data', chunk => {
chunks.push(chunk); // Just buffer
});Problem: Not cleaning up event listeners
Solution: Remove listeners and handle errors
const cleanup = () => {
req.removeAllListeners();
res.removeAllListeners();
};
req.on('error', cleanup);
res.on('error', cleanup);- Validate all inputs including headers and paths
- Sanitize user data before forwarding
- Implement rate limiting in examples
- Don't forward sensitive headers unnecessarily
- Validate content-type headers
- Handle authorization properly
- Be respectful and inclusive
- Help others learn and grow
- Focus on what's best for the community
- Welcome newcomers and questions
- Check documentation first
- Search existing issues
- Ask in discussions for general questions
- File issues for bugs or feature requests
Contributors will be recognized in:
- README.md contributors section
- Release notes for significant contributions
- GitHub contributors page
Thank you for helping make Node-Go Reverse Proxy better! 🚀