Thank you for your interest in contributing to the Lectionary API! This document outlines the development workflow, code quality standards, and guidelines for contributors.
- Node.js 20.0.0 or higher
- npm (comes with Node.js)
- Git
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/yourusername/lectio-api.git
cd lectio-apinpm installThis will automatically:
- Install all project dependencies
- Set up Husky pre-commit hooks via the
preparescript - Initialize the development environment
Copy the example environment file and configure it:
cp .env.example .env
# Edit .env with your database credentials and other settingsThis project uses automated code quality checks to ensure consistency and prevent broken code from being committed.
The project uses Husky and lint-staged to run automated checks before every commit. These hooks will:
- TypeScript Type Checking - Ensures all TypeScript code compiles without errors
- ESLint - Checks code style and catches potential issues (with auto-fix for staged files)
- Tests - Runs the test suite to ensure functionality isn't broken
- Build Verification - Confirms the project builds successfully
When you run git commit, the following sequence occurs:
🔍 Running pre-commit checks...
📝 Type checking with TypeScript...
🧹 Linting staged files...
🧪 Running tests...
🏗️ Building project...
✅ All pre-commit checks passed! Ready to commit.If any check fails, the commit will be blocked with clear error messages.
You can run these checks manually at any time:
# Type checking
npm run typecheck
# Linting (with auto-fix)
npm run lint
npm run lint:fix
# Tests
npm test
npm run test:watch
npm run test:coverage
# Build
npm run buildgit checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-description- Write clean, well-documented TypeScript code
- Follow the existing code style and patterns
- Add tests for new functionality
- Update documentation as needed
The pre-commit hooks will automatically run. If they pass:
git add .
git commit -m "feat: add new feature description"If pre-commit checks fail, fix the issues and try again.
git push origin feature/your-feature-nameThen create a pull request through GitHub.
- Use strict TypeScript configuration (already configured)
- Avoid
anytypes - use specific types or proper generics - Include return types for functions (enforced by ESLint)
- Use proper error handling with typed error objects
The project uses these key ESLint rules:
- @typescript-eslint/no-unused-vars: Error for unused variables (except those starting with
_) - @typescript-eslint/explicit-function-return-type: Warning for missing return types
- @typescript-eslint/no-explicit-any: Warning for
anyusage - prefer-const: Error - use
constwhen variables aren't reassigned - no-console: Warning - use proper logging instead
- comma-dangle: Error - require trailing commas in multiline structures
- Write unit tests for all business logic
- Write integration tests for API endpoints
- Maintain >80% code coverage (enforced)
- Use descriptive test names and clear assertions
# Reinstall dependencies and reinitialize Husky
rm -rf node_modules package-lock.json
npm install# Fix TypeScript errors first
npm run typecheck
# Fix the reported errors, then commit again# Try auto-fixing first
npm run lint:fix
# Manually fix remaining issues, then commit# Run tests to see failures
npm test
# Fix failing tests, then commit# Check build output
npm run build
# Fix compilation issues, then commit# Only use in emergencies - not recommended
git commit --no-verify -m "emergency fix"Note: This should only be used in extreme circumstances. The CI/CD pipeline will still run these checks.
If you encounter issues:
- Check this documentation first
- Run the failing command manually to see detailed error messages
- Check existing GitHub issues for similar problems
- Create a new issue with:
- Your Node.js and npm versions
- The complete error message
- Steps to reproduce the problem
lectio-api/
├── src/ # Source code
│ ├── controllers/ # API endpoint handlers
│ ├── services/ # Business logic
│ ├── models/ # Database models
│ ├── middleware/ # Express middleware
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── tests/ # Test files
├── .husky/ # Git hooks
├── dist/ # Compiled output
└── docs/ # Documentation
For database schema changes:
# Generate migration
npm run db:generate -- -n MigrationName
# Run migrations
npm run db:migrate
# Validate entities
npm run entities:validate# Build and run with Docker
npm run docker:build
npm run docker:up
# View logs
npm run docker:logs
# Clean up
npm run docker:clean- Ensure all tests pass and code is properly linted
- Update version in
package.json - Update
CHANGELOG.mdwith new features and fixes - Create a pull request with the release changes
- After merge, tag the release
- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and improve
- Follow the established patterns and conventions
Feel free to:
- Open an issue for bugs or feature requests
- Start a discussion for questions or ideas
- Submit pull requests for improvements
Thank you for contributing to the Lectionary API!