Skip to content

TheRealZurvan/ts-template

πŸš€ TypeScript Template

License TypeScript Bun Biome

A modern, production-ready template for TypeScript projects with all the essential tools and configurations you need to get started quickly! 🎯

✨ Features

This template comes pre-configured with:

  • πŸ”₯ Bun Runtime: Ultra-fast JavaScript runtime and package manager
  • πŸ“˜ TypeScript: Type-safe JavaScript with modern ES features
  • 🧹 Biome: Fast linter and formatter (Prettier + ESLint replacement)
  • πŸ”§ Modern Configuration: ESNext target with strict type checking
  • 🚨 Git Integration: Pre-configured with Biome VCS integration
  • πŸͺ Git Hooks: Lefthook for automated quality checks
  • πŸ“‹ Conventional Commits: Cocogitto (cog) for commit message validation and changelog generation
  • πŸ“ GitHub Templates: CODE_OF_CONDUCT.md, SECURITY.md, and LICENSE included
  • ⚑ Proto Tool Manager: Automated tool management with moonrepo proto

πŸš€ Quick Start

Prerequisites

  • proto: A multi-language version manager that will manage all required tools
  • Alternatively, you can install tools separately:
    • Bun: Ultra-fast JavaScript runtime and package manager
    • Biome: Fast linter and formatter (Prettier + ESLint replacement)
    • Cocogitto: Conventional commits tooling
    • Lefthook: Fast and powerful Git hooks manager

Installation

  1. Use this template by clicking the "Use this template" button on GitHub

  2. Clone your new repository:

    git clone https://github.com/yourusername/your-project-name.git
    cd your-project-name
  3. Install tools and dependencies:

    Option A: Automated Setup (Recommended)

    # Run the automated installation script
    ./scripts/install.sh
    
    # Install project dependencies
    bun install

    Option B: Manual Setup

    # Install proto (if not already installed)
    bash -c "$(curl -fsSL https://moonrepo.dev/install/proto.sh)"
    
    # Install all required tools (bun, biome, cog, lefthook) using proto
    proto use
    
    # Install Git hooks with Lefthook
    lefthook install
    
    # Install project dependencies
    bun install

πŸƒβ€β™‚οΈ Running the Project

# Start the development server (with watch mode)
bun run dev

# Start the production server
bun run start

πŸ› οΈ Development

Available Scripts

Script Description
bun run start Start the production server
bun run dev Start development server with file watching
bun run lint Run Biome linter
bun run format Format code with Biome
bun run prepare Install Lefthook Git hooks

🧹 Code Quality

This template uses Biome for both linting and formatting:

# Check for linting issues
bun run lint

# Auto-fix linting issues and format code
bun run format

πŸͺ Git Hooks & Conventional Commits

This template includes Lefthook for automated Git hooks

Automatic Quality Checks

Git hooks will automatically run on:

  • Pre-commit: Format code, run linter, and type-check
  • Commit-msg: Validate commit message format
  • Pre-push: Final lint and type checks

Conventional Commits

All commit messages must follow the Conventional Commits specification:

# βœ… Valid commit messages
git commit -m "feat: add user authentication"
git commit -m "fix: resolve memory leak in data processing"
git commit -m "docs: update API documentation"
git commit -m "refactor: simplify error handling logic"

# ❌ Invalid commit messages
git commit -m "add feature"           # Missing type
git commit -m "Fix bug"              # Wrong case
git commit -m "feat!: breaking change" # Use BREAKING CHANGE footer instead

Available commit types:

  • feat - New features
  • fix - Bug fixes
  • docs - Documentation changes
  • style - Code style changes (formatting, etc.)
  • refactor - Code refactoring
  • perf - Performance improvements
  • test - Adding or updating tests
  • build - Build system changes
  • ci - CI configuration changes
  • chore - Other changes (maintenance, etc.)
  • revert - Reverting previous commits

Managing Git Hooks

# Install hooks (automatically runs after `bun install`)
bun run prepare

# Skip hooks for a single commit (use sparingly)
git commit -m "feat: add feature" --no-verify

# Temporarily disable hooks
lefthook uninstall

# Re-enable hooks
lefthook install

πŸ“ Project Structure

β”œβ”€β”€ src/
β”‚   └── index.ts          # Main application entry point
β”œβ”€β”€ biome.json           # Biome configuration
β”œβ”€β”€ tsconfig.json        # TypeScript configuration
β”œβ”€β”€ package.json         # Project dependencies and scripts
└── README.md            # You are here! πŸ“

πŸ”§ Configuration

TypeScript Configuration

The tsconfig.json is configured for modern TypeScript development:

  • ESNext target and library
  • Strict type checking enabled
  • Bun-optimized module resolution
  • React JSX support ready

Biome Configuration

The biome.json includes:

  • All recommended rules are enabled
  • Tab indentation (configurable)
  • Git integration
  • Import organization

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run the linter and formatter: bun run format
  5. Commit your changes (git commit -m 'Add some amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

πŸ“‹ Customization

To customize this template for your project:

  1. Update package.json with your project details
  2. Modify the server in src/index.ts to fit your needs
  3. Adjust TypeScript/Biome configs as needed
  4. Update this README with your project-specific information

πŸ”’ Security

Please see SECURITY.md for our security policy and how to report security vulnerabilities.

πŸ“„ License

This project is licensed under the Apache Licenseβ€”see the LICENSE file for details.

πŸ™ Acknowledgments

  • Bun for the amazing runtime
  • Biome for fast linting and formatting
  • TypeScript for type safety
  • Lefthook for fast and powerful Git hooks management
  • Cocogitto for conventional commits tooling and changelog generation
  • Proto for multi-language version management

Happy coding! πŸŽ‰ If you find this template useful, please give it a ⭐️

About

A modern, production-ready template for TypeScript projects with all the essential tools

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published