Contributing to RamAPI
Thank you for your interest in contributing to RamAPI! This guide will help you get started.
Table of Contents
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Documentation
- Submitting Pull Requests
- Code Standards
Code of Conduct
Our Pledge
We are committed to providing a welcoming and inclusive environment for all contributors.
Expected Behavior
- Be respectful and constructive
- Welcome newcomers
- Focus on what is best for the community
- Show empathy towards others
Unacceptable Behavior
- Harassment or discriminatory language
- Personal attacks
- Trolling or insulting comments
- Publishing others' private information
Getting Started
Prerequisites
- Node.js 18+ installed
- Git installed
- Basic TypeScript knowledge
- Familiarity with Node.js APIs
Find an Issue
- Browse open issues (opens in a new tab)
- Look for issues labeled
good first issueorhelp wanted - Comment on the issue to let others know you're working on it
Ask Questions
- Open a discussion (opens in a new tab) for questions
- Join our community chat (if available)
- Check existing documentation first
Development Setup
1. Fork and Clone
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/ramapi.git
cd ramapi2. Install Dependencies
npm install3. Build the Project
npm run build4. Run Tests
npm test5. Run Examples
npm run example:basicProject Structure
ramapi/
├── src/ # Source code
│ ├── core/ # Core framework
│ ├── middleware/ # Built-in middleware
│ ├── auth/ # Authentication
│ ├── observability/ # Tracing, profiling
│ ├── protocols/ # GraphQL, gRPC
│ └── adapters/ # HTTP adapters
├── examples/ # Example applications
├── tests/ # Test files
├── docs/ # Documentation
└── benchmarks/ # Performance benchmarksMaking Changes
1. Create a Branch
git checkout -b feature/my-feature
# or
git checkout -b fix/my-bugfixBranch naming:
feature/for new featuresfix/for bug fixesdocs/for documentationperf/for performance improvementsrefactor/for code refactoring
2. Make Your Changes
- Write clean, readable code
- Follow existing code style
- Add comments for complex logic
- Keep changes focused and atomic
3. Write Tests
All code changes should include tests:
import { describe, it, expect } from 'vitest';
import { createApp } from '../src/index.js';
describe('My Feature', () => {
it('should work correctly', () => {
const app = createApp();
// Test implementation
expect(true).toBe(true);
});
});4. Update Documentation
- Add/update JSDoc comments
- Update relevant markdown docs
- Add examples if applicable
Testing
Run All Tests
npm testRun Specific Test File
npm test -- router.test.tsRun Tests in Watch Mode
npm test -- --watchRun Tests with Coverage
npm run test:coverageTest Guidelines
- Write tests for all new features
- Fix any failing tests
- Aim for >80% code coverage
- Test edge cases and error conditions
- Use descriptive test names
Example:
describe('Router', () => {
describe('get()', () => {
it('should register GET route', () => {
// Test implementation
});
it('should handle route parameters', () => {
// Test implementation
});
it('should throw error for invalid path', () => {
// Test implementation
});
});
});Documentation
Inline Documentation
Use JSDoc comments:
/**
* Create a new RamAPI application
*
* @param config - Server configuration
* @returns Server instance
*
* @example
* ```typescript
* const app = createApp({
* port: 3000,
* observability: { tracing: { enabled: true } }
* });
* ```
*/
export function createApp(config?: ServerConfig): Server {
// Implementation
}Markdown Documentation
- Use clear headings
- Include code examples
- Add usage notes
- Link to related docs
Documentation Structure
docs/
├── getting-started/
├── core-concepts/
├── middleware/
├── guides/
└── api-reference/Submitting Pull Requests
Before Submitting
- Tests pass locally
- Code follows style guide
- Documentation updated
- Commit messages are clear
- Branch is up to date with main
PR Process
- Push your branch:
git push origin feature/my-feature-
Open PR on GitHub
-
Fill out PR template:
- Description of changes
- Related issues
- Testing performed
- Breaking changes (if any)
-
Respond to feedback:
- Address review comments
- Make requested changes
- Push updates to your branch
-
Wait for approval:
- At least one maintainer approval required
- CI tests must pass
- No merge conflicts
PR Title Format
type(scope): description
Examples:
feat(router): add support for regex patterns
fix(auth): resolve token expiration issue
docs(guides): add migration guide
perf(core): optimize route matching algorithmTypes:
feat: New featurefix: Bug fixdocs: Documentationstyle: Code style (formatting)refactor: Code refactoringperf: Performance improvementtest: Test updateschore: Build/tooling changes
Code Standards
TypeScript Style
// ✅ Good
export interface UserConfig {
name: string;
email: string;
}
export async function getUser(id: string): Promise<User> {
const user = await db.findById(id);
return user;
}
// ❌ Bad
export interface user_config {
Name: string;
Email: string;
}
export function GetUser(id) {
return db.findById(id);
}Naming Conventions
- Classes:
PascalCase(e.g.,JWTService,Router) - Functions:
camelCase(e.g.,createApp,authenticate) - Constants:
UPPER_SNAKE_CASE(e.g.,MAX_RETRIES) - Interfaces:
PascalCase(e.g.,ServerConfig,Context) - Types:
PascalCase(e.g.,HTTPMethod,Handler)
Code Formatting
We use Prettier and ESLint:
# Format code
npm run format
# Lint code
npm run lint
# Fix lint issues
npm run lint:fixPerformance Considerations
- Avoid unnecessary allocations
- Use pre-compilation where possible
- Profile performance-critical code
- Document performance characteristics
Example:
// ✅ Good - pre-compile regex
const pattern = /^\/users\/\d+$/;
export function matchRoute(path: string): boolean {
return pattern.test(path);
}
// ❌ Bad - compiles regex every call
export function matchRoute(path: string): boolean {
return /^\/users\/\d+$/.test(path);
}Benchmarking
Run Benchmarks
npm run benchmarkAdding Benchmarks
import { benchmark } from './utils/benchmark.js';
benchmark('route matching', () => {
app.findRoute('GET', '/users/123');
});Performance Requirements
- No performance regressions
- Document performance impact of changes
- Include benchmarks for performance-related PRs
Release Process
(For maintainers)
Version Bumping
# Patch (0.1.0 -> 0.1.1)
npm version patch
# Minor (0.1.0 -> 0.2.0)
npm version minor
# Major (0.1.0 -> 1.0.0)
npm version majorPublishing
npm run build
npm publishQuestions?
- Documentation: Check complete documentation
- Discussions: Ask questions on GitHub Discussions
- Issues: Report bugs via GitHub Issues
- Email: Contact maintainers (if provided)
Recognition
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Recognized in documentation
License
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to RamAPI!