Use Cases
Boiler is designed to eliminate repetitive coding tasks by storing and reusing code across projects. Here are practical use cases to get the most out of it.
1. Avoid Installing Entire Packages for Small Utilities
Section titled “1. Avoid Installing Entire Packages for Small Utilities”Have you ever thought: Sometimes we add a package even for a small use case?
The Problem:
# Just need one function from lodash?npm install lodash # 1.4MB for one function!
# Need a date formatter?npm install moment # 289KB for basic formatting!Boiler Solution:
// debounce.js// __author Your Name// __desc Debounce utility without lodash
function debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); };}
module.exports = debounce;# Store oncebl store debounce.js
# Reuse everywhere - no package needed!bl add debounceBenefits:
- Zero dependencies - No node_modules bloat
- Lightweight - Only the code you need
- Custom tailored - Modify to your exact needs
- Bundle size - Smaller production builds
Perfect for: Small utilities like debounce, throttle, formatters, validators, parsers, etc.
2. Store & Reuse API Middleware
Section titled “2. Store & Reuse API Middleware”Scenario: You use the same authentication middleware in every Express project.
# Store it oncecd my-express-projectbl store middleware/auth.js
# Use in any new projectcd new-projectbl add authResult: Never write verifyToken() or requireAuth() again.
3. Database Connection Configs
Section titled “3. Database Connection Configs”Scenario: MongoDB/PostgreSQL connection setup is identical across microservices.
# Store your database configbl store config/db.js
# Add to any service instantlycd user-servicebl add dbPerfect for: Microservice architectures where consistency matters.
4. Error Handlers & Logging Utilities
Section titled “4. Error Handlers & Logging Utilities”Scenario: You have a custom error handler and logger you always use.
# Store utilitiesbl store utils/errorHandler.jsbl store utils/appLogger.js
# Add both to new projectbl add errorHandlerbl add appLoggerWhy it matters: Consistent error handling across all projects.
5. Project Boilerplates (Stacks)
Section titled “5. Project Boilerplates (Stacks)”Scenario: You repeatedly scaffold Express APIs with the same structure.
# Create your perfect Express template oncecd my-express-templatebl init # Creates boiler.stack.json
# Customize boiler.stack.json to exclude node_modules, .env# Then store the entire structurebl store
# Start new projects in secondsmkdir new-api && cd new-apibl add express-api@1npm installUse for:
- Express/Fastify APIs
- Next.js starters
- Django REST templates
- Microservice scaffolds
6. Team Snippet Library
Section titled “6. Team Snippet Library”Scenario: Your team needs standardized code patterns shared across machines.
# Store team-approved patterns in a shared GitHub/GitLab repo# Then any team member can fetch them:
# One-time registry setup per machinebl conf --set-registry https://github.com/myteam/boiler-snippets
# Fetch and save to local store (reusable offline after)bl add jwtHelper -rbl add validation -rbl add rateLimiter -r
# Or one-shot without saving to local storebl use https://github.com/myteam/boiler-snippets:js/jwtHelper.jsBenefit: Code consistency across the entire team, across machines - no manual file sharing needed.
7. Versioned Code Evolution
Section titled “7. Versioned Code Evolution”Scenario: You improve a utility and want to keep both versions.
# Store version 1bl store utils/emailService.js# → Saved as emailService@1.js
# Later, improve it and store v2# Update __version to 2 in file commentsbl store utils/emailService.js# → Saved as emailService@2.js
# Use specific versionsbl add emailService@1 # Old projectsbl add emailService@2 # New projectsWhen to use: Gradual migration without breaking old projects.
8. Cross-Language Snippets
Section titled “8. Cross-Language Snippets”Scenario: You work in multiple languages and want to store patterns for all.
# Python async wrapperbl init -n# → Create asyncWrapper.py with __author and __versionbl store asyncWrapper.py
# JavaScript promise handlerbl init -n# → Create promiseHandler.jsbl store promiseHandler.js
# Go error wrapperbl init -n# → Create errorWrapper.gobl store errorWrapper.goPerfect for: Polyglot developers managing multiple tech stacks.
9. Configuration Files
Section titled “9. Configuration Files”Scenario: You use the same ESLint, Prettier, or Docker configs everywhere.
# Store configsbl store .eslintrc.jsonbl store .prettierrcbl store Dockerfile
# Add to new projectsbl add eslintrcbl add prettierrcbl add DockerfileSaves time on: Project setup and maintaining consistency.
10. Testing Utilities
Section titled “10. Testing Utilities”Scenario: You have custom test helpers and fixtures.
# Store test utilitiesbl store tests/helpers/mockData.jsbl store tests/helpers/testSetup.js
# Add to new test suitesbl add mockDatabl add testSetupWhy: Faster test setup with proven patterns.
11. Quick Script Deployment
Section titled “11. Quick Script Deployment”Scenario: You have shell scripts for deployment, backups, or automation.
# Store scriptsbl store scripts/deploy.shbl store scripts/db-backup.sh
# Use in CI/CD or other projectsbl add deploybl add db-backupUse for: DevOps automation and deployment pipelines.
Best Practices
Section titled “Best Practices”1. Initialize Before Storing
Section titled “1. Initialize Before Storing”Always run bl init to add metadata (author, version, description) before storing.
2. Use Descriptive Names
Section titled “2. Use Descriptive Names”# Badbl store helper.js
# Goodbl store jwtTokenHelper.js3. Version Strategically
Section titled “3. Version Strategically”- Increment version for breaking changes
- Keep old versions for legacy projects
4. Store Stacks with Proper Ignore Patterns
Section titled “4. Store Stacks with Proper Ignore Patterns”Edit boiler.stack.json to exclude:
{ "ignore": [ "node_modules", ".env", "dist", ".git" ]}5. Search Before Creating
Section titled “5. Search Before Creating”bl search jwt# Check if similar utility already existsCommon Workflows
Section titled “Common Workflows”New Project Setup
Section titled “New Project Setup”# Add stack templatebl add express-api
# Add common utilitiesbl add errorHandlerbl add loggerbl add dbConfig
# Start codingnpm installnpm startMicroservice Development
Section titled “Microservice Development”# Store shared middleware oncebl store auth.middleware.jsbl store cors.middleware.js
# Use across all servicescd user-service && bl add auth && bl add corscd order-service && bl add auth && bl add corscd payment-service && bl add auth && bl add corsPersonal Code Library
Section titled “Personal Code Library”# Store everything you frequently usebl store utils/*
# List your librarybl ls
# Add what you needbl add <snippet-name>Tips & Tricks
Section titled “Tips & Tricks”-
Alias frequently used snippets:
Terminal window bl config # Edit config# Add aliases for quick access -
Search with keywords:
Terminal window bl search middlewarebl search validation -
Check info before adding:
Terminal window bl info auth@2# See author, version, description -
Clean unused resources:
Terminal window bl clean --snippetsbl clean --stacks
Next Steps
Section titled “Next Steps”- Quick Start Guide - Get started in 5 minutes
- Commands Reference - Complete command documentation
- Installation - Setup instructions