Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:07:10 +08:00
commit 169a5fc5cd
99 changed files with 25560 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
# Bad Commit Message Examples (and How to Fix Them)
## ❌ Too Vague
```
fix: fix bug
```
**Problem**: Doesn't explain what bug was fixed
**Better**:
```
fix(auth): prevent session timeout during active use
Fixed bug where user sessions expired after 30 minutes
even during active usage. Now sessions extend while user
is interacting with the application.
Fixes #456
```
## ❌ Wrong Tense
```
feat: added dark mode
```
**Problem**: Should be imperative mood ("add" not "added")
**Better**:
```
feat(ui): add dark mode toggle
Implemented dark mode with localStorage persistence
and system preference detection.
Closes #789
```
## ❌ Subject Too Long
```
feat: add a new user profile editing feature that allows users to update their name, email, and profile picture
```
**Problem**: Subject exceeds 50 characters, should be concise
**Better**:
```
feat(profile): add user profile editing
Users can now update their name, email, and profile
picture from the settings page. Changes are validated
server-side and saved to the database.
Closes #123
```
## ❌ No Type
```
update README
```
**Problem**: Missing type prefix
**Better**:
```
docs(readme): add API authentication examples
Added code examples showing how to authenticate API
requests using JWT tokens.
```
## ❌ Multiple Unrelated Changes
```
feat: add login and fix cart bug and update dependencies
```
**Problem**: Should be 3 separate commits
**Better**: Split into:
```
feat(auth): add user login functionality
```
```
fix(cart): resolve item duplication issue
```
```
chore(deps): update npm packages to latest versions
```
## ❌ Description of HOW Instead of WHY
```
fix: changed if statement to switch statement
```
**Problem**: Describes implementation detail, not the reason
**Better**:
```
refactor(validation): simplify input validation logic
Replaced nested if statements with switch statement
for better readability and easier maintenance. No
functional changes.
```
## ❌ Capitalized Subject
```
feat: Add Dark Mode Support
```
**Problem**: Subject should be lowercase
**Better**:
```
feat(ui): add dark mode support
```
## ❌ Period at End of Subject
```
fix: resolve login timeout issue.
```
**Problem**: Subject shouldn't end with period
**Better**:
```
fix(auth): resolve login timeout issue
Increased session timeout from 15 to 30 minutes to
prevent premature logouts during form filling.
Fixes #567
```
## ❌ No Context
```
fix: it works now
```
**Problem**: Completely uninformative
**Better**:
```
fix(payment): resolve Stripe webhook signature validation
Fixed HMAC signature verification by using raw request
body instead of parsed JSON. Webhooks now process correctly.
Fixes #890
```
## ❌ Missing Issue Reference
```
feat: add two-factor authentication
Implemented TOTP-based 2FA with QR code generation.
```
**Problem**: Should reference the issue/story
**Better**:
```
feat(auth): add two-factor authentication
Implemented TOTP-based 2FA with QR code generation
for enhanced account security.
Closes #234, STORY-042
```

View File

@@ -0,0 +1,120 @@
# Good Commit Message Examples
## Simple Feature Addition
```
feat(auth): add password reset via email
Users can now request a password reset link sent to their
registered email address. The link expires after 1 hour.
Closes #456
```
## Bug Fix with Context
```
fix(cart): prevent duplicate items in shopping cart
Fixed race condition where clicking "Add to Cart" rapidly
could add the same item multiple times. Added debouncing
and server-side validation.
Fixes #789
```
## Refactoring with Explanation
```
refactor(api): extract authentication middleware
Moved authentication logic from individual route handlers
into reusable middleware. This reduces code duplication
and makes auth logic easier to maintain and test.
No behavioral changes.
```
## Breaking Change
```
feat(api)!: migrate to v2 response format
BREAKING CHANGE: All API endpoints now return data wrapped
in a standardized envelope format.
Before: { id: 1, name: "..." }
After: { data: { id: 1, name: "..." }, meta: { version: 2 } }
Migration guide: docs/api-v2-migration.md
Closes #234
```
## Multiple Related Changes
```
feat(profile): add profile editing and avatar upload
- Implemented profile form with field validation
- Added avatar upload with client-side image cropping
- Created PUT /api/users/:id endpoint
- Added error handling for file size limits
- Wrote unit tests for profile update logic
Closes #123, #124
```
## Documentation
```
docs(readme): add installation instructions for Docker
Added step-by-step guide for running the application
in Docker containers, including environment variable
configuration and volume mounting.
```
## Performance Improvement
```
perf(db): add index on user email column
Query performance for user lookup by email improved from
~500ms to ~5ms. Added composite index on (email, status)
for common query patterns.
```
## Dependency Update
```
chore(deps): upgrade React to v18.2
Updated React and React DOM to latest stable version.
Migrated deprecated lifecycle methods in UserProfile
and Dashboard components.
Tested with full E2E suite - all tests passing.
```
## CI/CD Change
```
ci(github): add automated dependency updates
Configured Dependabot to create PRs for npm package
updates weekly. Auto-merge enabled for patch updates
that pass all tests.
```
## Revert
```
revert: feat(payments): add Stripe integration
This reverts commit abc123def456.
Stripe webhook validation is failing in production.
Reverting to investigate HMAC signature verification
before re-deploying.
```