DocsContributingContributing Guidelines

Contributing Guidelines

Thank you for your interest in contributing to lomi. This guide will help you get started.

Getting Started

1. Development Setup

# Clone repository
git clone https://github.com/lomi/api
cd api
 
# Install dependencies
npm install
 
# Set up environment
cp .env.example .env

2. Running Tests

# Run all tests
npm test
 
# Run specific tests
npm test -- --grep "payment"
 
# Run with coverage
npm run test:coverage

3. Local Development

# Start development server
npm run dev
 
# Build documentation
npm run docs:dev
 
# Run linting
npm run lint

Contributing Process

1. Find an Issue

  • Check open issues
  • Look for good first issue label
  • Ask questions if needed

2. Fork and Clone

# Fork via GitHub UI
 
# Clone your fork
git clone https://github.com/YOUR_USERNAME/api
cd api
 
# Add upstream remote
git remote add upstream https://github.com/lomi/api

3. Create Branch

# Update main
git checkout main
git pull upstream main
 
# Create branch
git checkout -b feature/my-contribution

4. Make Changes

# Make your changes
git add .
git commit -m "feat: add new feature"
 
# Keep branch updated
git fetch upstream
git rebase upstream/main

5. Submit PR

  • Push changes to your fork
  • Create pull request
  • Fill out PR template
  • Request review

Code Standards

1. TypeScript

// Use TypeScript for type safety
interface PaymentRequest {
  amount: number;
  currency: string;
  provider_code: string;
}
 
function processPayment(request: PaymentRequest): Promise<void> {
  // Implementation
}

2. Testing

describe('Payment Processing', () => {
  it('should process valid payment', async () => {
    const request = {
      amount: 1000,
      currency: 'XOF',
      provider_code: 'ORANGE_MONEY'
    };
    
    const result = await processPayment(request);
    expect(result).toBeDefined();
  });
});

3. Documentation

/**
 * Process a payment request
 * @param request - Payment request details
 * @returns Promise resolving to payment result
 * @throws {ValidationError} If request is invalid
 * @throws {PaymentError} If payment processing fails
 */
async function processPayment(
  request: PaymentRequest
): Promise<PaymentResult> {
  // Implementation
}

Pull Request Guidelines

1. Title Format

<type>(<scope>): <description>
 
# Examples
feat(payments): add Wave provider support
fix(webhooks): handle timeout errors
docs(api): update authentication guide

2. Description

## Changes
- Added Wave payment provider
- Implemented webhook handling
- Updated documentation
 
## Testing
- Added unit tests
- Manual testing completed
- All CI checks passing
 
## Related Issues
Closes #123

Review Process

1. Before Submitting

  • Tests passing
  • Code linted
  • Documentation updated
  • Commits squashed

2. During Review

  • Respond to feedback
  • Make requested changes
  • Keep PR updated

3. After Merge

  • Delete branch
  • Update related issues
  • Monitor deployment

Best Practices

1. Commits

# Good
git commit -m "feat(auth): add API key rotation"
 
# Bad
git commit -m "fixed stuff"

2. Code Style

// Good
function validateAmount(amount: number): boolean {
  return amount > 0 && amount <= 1000000;
}
 
// Bad
function validate(a) {
  return a>0&&a<=1000000;
}

3. Error Handling

// Good
try {
  await processPayment(request);
} catch (error) {
  if (error instanceof ValidationError) {
    // Handle validation error
  } else if (error instanceof PaymentError) {
    // Handle payment error
  } else {
    // Handle unknown error
  }
}
 
// Bad
try {
  await processPayment(request);
} catch (error) {
  console.error(error);
}

Next Steps