Contributing to EdgeMaster
Thank you for your interest in contributing to EdgeMaster! We welcome contributions from the community to make EdgeMaster even better.
Ways to Contribute
🐛 Report Bugs
Found a bug? Open an issue with:
- Clear bug description
- Steps to reproduce
- Expected vs actual behavior
- EdgeMaster version and environment
💡 Request Features
Have an idea? Open a feature request with:
- Clear feature description
- Use case and motivation
- Proposed implementation (optional)
📝 Improve Documentation
- Fix typos or errors
- Add examples or clarifications
- Write tutorials
- Translate documentation
💻 Submit Code
- Fix bugs
- Implement features
- Improve performance
- Add tests
Development Setup
Prerequisites
- Node.js 16.0.0 or higher
- npm 7+
- Git
- TypeScript knowledge
Setup Steps
- Fork the repository
Visit https://github.com/sharif3271/edge-master and click "Fork"
- Clone your fork
git clone https://github.com/YOUR_USERNAME/edge-master.git
cd edge-master
- Install dependencies
npm install
- Create a branch
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix
Development Workflow
Project Structure
edge-master/
├── src/ # Source code
│ ├── EdgeController.ts # Core controller
│ ├── RouteHandler.ts # Route handler
│ ├── Task.ts # Task implementation
│ ├── Utils.ts # Matcher utilities
│ ├── types/ # TypeScript types
│ ├── interceptors/ # Built-in interceptors
│ └── helpers/ # Helper functions
├── test/ # Test files
│ ├── EdgeController.test.ts
│ ├── RouteHandler.test.ts
│ └── Task.test.ts
├── example/ # Example applications
├── docs/ # Documentation
├─ ─ dist/ # Compiled output
└── coverage/ # Test coverage reports
Making Changes
- Write your code
Follow the existing code style and patterns:
// Use TypeScript strict mode
// Document public APIs with JSDoc
// Keep functions focused and testable
/**
* Example function documentation
* @param req - The incoming request
* @returns A response object
*/
export async function handleRequest(req: Request): Promise<Response> {
// Implementation
}
- Add tests
All new features and bug fixes must include tests:
// test/YourFeature.test.ts
import { describe, it, expect } from '@jest/globals';
import { YourFeature } from '../src/YourFeature';
describe('YourFeature', () => {
it('should do something', () => {
const result = YourFeature.doSomething();
expect(result).toBe(expected);
});
});
- Run tests
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Coverage must be >= 90%
- Build the project
# TypeScript compilation
npm run build
# Build with minification
npm run build:minify
- Verify types
# Check TypeScript types
npx tsc --noEmit
Code Style Guidelines
TypeScript
- Use strict mode (
strict: true) - Prefer
constoverlet - Use arrow functions for callbacks
- Avoid
anytypes when possible - Export types for public APIs
// ✅ Good
export interface MyConfig {
timeout: number;
retries?: number;
}
export const processData = async (config: MyConfig): Promise<Result> => {
const { timeout, retries = 3 } = config;
// ...
};
// ❌ Bad
export function processData(config: any) {
var timeout = config.timeout;
// ...
}
Naming Conventions
- Classes:
PascalCase(e.g.,EdgeController) - Functions:
camelCase(e.g.,handleRequest) - Constants:
UPPER_SNAKE_CASE(e.g.,DEFAULT_TIMEOUT) - Interfaces:
PascalCasewithIprefix (e.g.,IRequestInterceptor) - Types:
PascalCase(e.g.,RequestHandler)
Comments & Documentation
- Document all public APIs with JSDoc
- Use comments to explain "why", not "what"
- Keep comments up-to-date with code changes
/**
* Intercepts incoming requests before route handling.
* Allows modification of the request or early termination via responder.
*
* @param ctx - The request context
* @returns Modified request object
*/
async intercept(ctx: Context): Promise<Request>;
Testing Guidelines
Test Coverage Requirements
- Line coverage: Minimum 90%
- Function coverage: Minimum 100%
- Branch coverage: Minimum 85%
Test Structure
describe('Feature Name', () => {
// Setup
beforeEach(() => {
// Initialization
});
// Test cases
it('should handle normal case', () => {
// Arrange
const input = createInput();
// Act
const result = processInput(input);
// Assert
expect(result).toBeDefined();
});
it('should handle edge case', () => {
// Test edge cases
});
it('should throw error for invalid input', () => {
// Test error cases
expect(() => process(null)).toThrow();
});
});
Testing Best Practices
- Test one thing per test case
- Use descriptive test names
- Test happy paths and error paths
- Mock external dependencies
- Keep tests fast and isolated
Pull Request Process
Before Submitting
Checklist:
- Code follows project style guidelines
- Tests added/updated and passing
- Test coverage >= 90%
- Documentation updated
- Build succeeds (
npm run build) - TypeScript types check passes
- No linting errors
- Commits follow conventional commits
PR Template
Use this template for your pull request:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
How has this been tested?
## Checklist
- [ ] Tests pass
- [ ] Coverage >= 90%
- [ ] Documentation updated
- [ ] No breaking changes (or documented)
Review Process
- Submit your PR
- Wait for CI checks to pass
- Address review feedback
- Maintainers will merge when approved
Commit Message Guidelines
Follow Conventional Commits:
Format
<type>(<scope>): <subject>
<body>
<footer>