Contributing
How to contribute to Bantai
Contributing
We welcome contributions to Bantai! This guide will help you get started with contributing to the project.
Development Setup
This project uses Turborepo for monorepo management and pnpm as the package manager.
Prerequisites
- Node.js >= 18
- pnpm >= 9.0.0
Setup
- Clone the repository
git clone https://github.com/bosquejun/bantai.git
cd bantai- Install dependencies
pnpm install- Build all packages
pnpm build- Run tests
# Run tests for a specific package
cd packages/core && pnpm test
# Or run all tests from root
pnpm test- Run type checking
pnpm check-types- Format code
pnpm formatProject Structure
bantai-dev/
├── packages/
│ ├── core/ # Main policy evaluation library
│ ├── with-rate-limit/ # Rate limiting extension
│ ├── with-storage/ # Storage extension
│ ├── storage-redis/ # Redis storage adapter
├── apps/
│ └── docs/ # Documentation site
└── turbo.json # Turborepo configurationCode Style Guidelines
- TypeScript: We use TypeScript with strict type checking
- Formatting: Code is formatted using the project's formatting rules
- Linting: ESLint is used for code quality
- Testing: All code should include appropriate tests
TypeScript
- Use explicit types where helpful
- Leverage TypeScript's type inference where appropriate
- Follow the existing code style in each package
Testing
- Write tests for all new features
- Ensure existing tests pass before submitting
- Use descriptive test names
How to Submit Pull Requests
-
Fork the repository
-
Create a feature branch
git checkout -b feature/your-feature-name-
Make your changes
- Write your code
- Add tests
- Update documentation if needed
- Ensure all tests pass
- Run type checking
-
Commit your changes
Follow our commit message conventions (see below).
-
Push to your fork
git push origin feature/your-feature-name-
Create a Pull Request
- Provide a clear description of your changes
- Reference any related issues
- Ensure CI checks pass
Commit Message Conventions
We follow conventional commit message format:
<type>(<scope>): <subject>
<body>
<footer>Types
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples
feat(core): add support for custom rule hooks
Add onAllow and onDeny hooks to rule definitions
for executing side effects.
Closes #123fix(storage): handle TTL expiration correctly
Fix issue where TTL was not properly applied
to stored values in memory storage.Development Workflow
Working on Core Package
cd packages/core
pnpm test:watch # Watch mode for tests
pnpm build # Build the packageWorking on Documentation
cd apps/docs
pnpm dev # Start development serverRunning All Tests
# From root directory
pnpm testCode of Conduct
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
Getting Help
- Issues: Open an issue on GitHub for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
- Documentation: Check the documentation for usage examples
Areas for Contribution
We welcome contributions in the following areas:
- Bug fixes: Fix issues reported in GitHub Issues
- New features: Propose and implement new features
- Documentation: Improve documentation and add examples
- Tests: Add test coverage
- Performance: Optimize existing code
- Examples: Add more example use cases
Review Process
- All pull requests require review
- Maintainers will review your code
- Address any feedback or requested changes
- Once approved, your PR will be merged
Thank you for contributing to Bantai!