create-charcole 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +200 -14
  2. package/README.md +137 -332
  3. package/bin/index.js +236 -55
  4. package/bin/lib/pkgManager.js +8 -25
  5. package/bin/lib/templateHandler.js +5 -42
  6. package/package.json +2 -2
  7. package/plans/V2_1_PLAN.md +20 -0
  8. package/template/js/.env.example +8 -0
  9. package/template/js/basePackage.json +11 -13
  10. package/template/js/src/app.js +4 -1
  11. package/template/js/src/modules/auth/auth.constants.js +3 -0
  12. package/template/js/src/modules/auth/auth.controller.js +29 -0
  13. package/template/js/src/modules/auth/auth.middlewares.js +19 -0
  14. package/template/js/src/modules/auth/auth.routes.js +9 -0
  15. package/template/js/src/modules/auth/auth.schemas.js +60 -0
  16. package/template/js/src/modules/auth/auth.service.js +67 -0
  17. package/template/js/src/modules/auth/package.json +6 -0
  18. package/template/js/src/repositories/user.repo.js +19 -0
  19. package/template/js/src/routes/index.js +25 -0
  20. package/template/js/src/routes/protected.js +13 -0
  21. package/template/ts/.env.example +8 -0
  22. package/template/ts/basePackage.json +20 -16
  23. package/template/ts/build.js +46 -0
  24. package/template/ts/src/app.ts +5 -4
  25. package/template/ts/src/middlewares/errorHandler.ts +15 -23
  26. package/template/ts/src/middlewares/requestLogger.ts +1 -1
  27. package/template/ts/src/middlewares/validateRequest.ts +1 -1
  28. package/template/ts/src/modules/auth/auth.constants.ts +6 -0
  29. package/template/ts/src/modules/auth/auth.controller.ts +32 -0
  30. package/template/ts/src/modules/auth/auth.middlewares.ts +46 -0
  31. package/template/ts/src/modules/auth/auth.routes.ts +9 -0
  32. package/template/ts/src/modules/auth/auth.schemas.ts +73 -0
  33. package/template/ts/src/modules/auth/auth.service.ts +106 -0
  34. package/template/ts/src/modules/auth/package.json +10 -0
  35. package/template/ts/src/modules/health/controller.ts +3 -3
  36. package/template/ts/src/repositories/user.repo.ts +33 -0
  37. package/template/ts/src/routes/index.ts +24 -0
  38. package/template/ts/src/routes/protected.ts +13 -0
  39. package/template/ts/src/server.ts +0 -1
  40. package/template/ts/src/utils/logger.ts +1 -1
  41. package/template/ts/tsconfig.json +14 -7
  42. package/template/js/ARCHITECTURE_DIAGRAMS.md +0 -283
  43. package/template/js/CHECKLIST.md +0 -279
  44. package/template/js/COMPLETE.md +0 -405
  45. package/template/js/ERROR_HANDLING.md +0 -393
  46. package/template/js/IMPLEMENTATION.md +0 -368
  47. package/template/js/IMPLEMENTATION_COMPLETE.md +0 -363
  48. package/template/js/INDEX.md +0 -290
  49. package/template/js/QUICK_REFERENCE.md +0 -270
  50. package/template/js/package-lock.json +0 -1253
  51. package/template/js/package.json +0 -28
  52. package/template/js/src/routes.js +0 -17
  53. package/template/js/test-api.js +0 -100
  54. package/template/ts/ARCHITECTURE_DIAGRAMS.md +0 -283
  55. package/template/ts/CHECKLIST.md +0 -279
  56. package/template/ts/COMPLETE.md +0 -405
  57. package/template/ts/ERROR_HANDLING.md +0 -393
  58. package/template/ts/IMPLEMENTATION.md +0 -368
  59. package/template/ts/IMPLEMENTATION_COMPLETE.md +0 -363
  60. package/template/ts/INDEX.md +0 -290
  61. package/template/ts/QUICK_REFERENCE.md +0 -270
  62. package/template/ts/package-lock.json +0 -2428
  63. package/template/ts/package.json +0 -32
  64. package/template/ts/src/app.js +0 -75
  65. package/template/ts/src/config/constants.js +0 -20
  66. package/template/ts/src/config/env.js +0 -26
  67. package/template/ts/src/middlewares/errorHandler.js +0 -180
  68. package/template/ts/src/middlewares/requestLogger.js +0 -33
  69. package/template/ts/src/middlewares/validateRequest.js +0 -42
  70. package/template/ts/src/modules/health/controller.js +0 -50
  71. package/template/ts/src/routes.js +0 -17
  72. package/template/ts/src/routes.ts +0 -16
  73. package/template/ts/src/server.js +0 -38
  74. package/template/ts/src/utils/AppError.js +0 -182
  75. package/template/ts/src/utils/logger.js +0 -73
  76. package/template/ts/src/utils/response.js +0 -51
  77. package/template/ts/test-api.js +0 -100
package/CHANGELOG.md CHANGED
@@ -1,25 +1,211 @@
1
1
  # Changelog
2
2
 
3
+ All notable changes to Charcole will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.1.0] – 2026-01-29
9
+
10
+ ### 🎉 Major Release: Repository Pattern & JWT Authentication
11
+
12
+ #### ✨ **New Features**
13
+
14
+ - **🎯 Revolutionary Repository Pattern** – Database abstraction layer for clean separation between business logic and data access
15
+ - **🔐 Optional JWT Authentication Module** – Complete auth system with register, login, logout, and protected routes
16
+ - **🧪 In-Memory Repository Implementation** – Test APIs instantly without database setup
17
+ - **🏗️ Repository Interfaces** – `BaseRepository` and `InMemoryRepository` for easy database switching
18
+ - **💻 Command-line project name support** – Create projects via `npx create-charcole@latest my-project`
19
+ - **📝 Enhanced TypeScript support** – Improved type definitions and compilation
20
+
21
+ #### 🚀 **New Architecture**
22
+
23
+ - **Database Abstraction Layer**: Switch between MongoDB, PostgreSQL, MySQL, etc., by changing one file
24
+ - **Modular Auth System**:
25
+ - Full user authentication (register/login/logout)
26
+ - JWT token generation and validation
27
+ - Password hashing with bcrypt
28
+ - Protected route middleware
29
+ - In-memory user repository for testing
30
+ - **Improved CLI**:
31
+ - Accept project name as command-line argument
32
+ - Better dependency merging for optional modules
33
+ - Cleaner project generation flow
34
+
35
+ #### 🔧 **Technical Improvements**
36
+
37
+ - **Fixed Module Copying**: Auth module properly excluded when user selects "No"
38
+ - **Fixed Package.json Merging**: Dependencies correctly merged into single package.json
39
+ - **Fixed TypeScript Compilation**: Clean builds with proper type definitions
40
+ - **Improved Path Resolution**: Better template directory structure handling
41
+
42
+ #### 📁 **Project Structure Updates**
43
+
44
+ - Added `src/modules/auth/` directory with complete auth system
45
+ - Modules now located in `src/modules/` instead of template root
46
+ - Cleaner dependency management with proper merging
47
+ - Enhanced CLI user experience with better flow control
48
+
49
+ #### 📦 **New Dependencies** (when auth selected)
50
+
51
+ - `jsonwebtoken@^9.0.0` for JWT authentication
52
+ - `bcryptjs@^2.4.3` for password hashing
53
+ - Type definitions for both libraries
54
+
55
+ #### 🎯 **Repository Pattern Benefits**
56
+
57
+ - ✅ Test without database setup
58
+ - ✅ Easy database migration
59
+ - ✅ Clean separation of concerns
60
+ - ✅ Better unit testing capabilities
61
+
62
+ #### 🔐 **Auth Module Structure**
63
+
64
+ ```
65
+ auth/
66
+ ├── auth.controller.js
67
+ ├── auth.middleware.js
68
+ ├── auth.constants.js
69
+ ├── auth.schemas.js
70
+
71
+ ```
72
+
73
+ ### 🚦 **Migration Notes from v2.0**
74
+
75
+ - Existing v2.0 projects remain compatible
76
+ - No breaking changes to core error handling or validation
77
+ - New projects get optional auth module
78
+ - Repository pattern is opt-in for existing codebases
79
+
80
+ ### ✅ **Known Issues**
81
+
82
+ - None reported
83
+
84
+ ---
85
+
3
86
  ## [2.0.0] – 2026-01-24
4
87
 
5
- ### Added
88
+ ### 🎉 **Major Release: TypeScript & JavaScript Support**
89
+
90
+ #### ✨ **New Features**
91
+
92
+ - **Full TypeScript project template support** – Production-ready TypeScript setup
93
+ - **Language selection at CLI runtime** – Choose between JavaScript or TypeScript during project creation
94
+ - **Improved project scaffolding structure** – Better organized template files
95
+ - **Enhanced developer experience** – Streamlined production setup process
96
+
97
+ #### 🔧 **Technical Improvements**
98
+
99
+ - **Improved template resolution logic** – More reliable project generation
100
+ - **Enhanced CLI output** – Better onboarding messages and instructions
101
+ - **Fixed template path resolution** – Resolved issues from previous versions
102
+ - **Fixed local CLI linking** – Improved development workflow
103
+
104
+ #### 📝 **Release Notes**
105
+
106
+ - This release focuses on stability and language parity
107
+ - Authentication and database modules intentionally excluded (added in v2.1)
108
+ - Foundation for future modular expansion
109
+
110
+ ---
111
+
112
+ ## [1.0.0] – 2025-12-15
113
+
114
+ ### 🎉 **Initial Release**
115
+
116
+ #### ✨ **Core Features**
117
+
118
+ - **Production-grade Express API boilerplate**
119
+ - **Centralized error handling system** – All errors flow through single handler
120
+ - **Error classification** – Operational vs programmer errors distinguished
121
+ - **Zod validation integration** – Type-safe schema validation with automatic error formatting
122
+ - **Structured logging** – Color-coded logs with context and stack traces
123
+ - **Consistent JSON responses** – Standardized format across all endpoints
124
+ - **Async error handling** – Promise rejection leaks prevented with asyncHandler
125
+ - **Graceful shutdown** – Proper cleanup on SIGTERM/SIGINT
126
+ - **Request logging** – Method, path, status, duration, IP automatically tracked
127
+
128
+ #### 🛡️ **Error Handling System**
129
+
130
+ - **AppError class hierarchy** – Specialized error types (ValidationError, NotFoundError, etc.)
131
+ - **Global error middleware** – Catches all unhandled errors
132
+ - **Production-safe responses** – Internal details hidden in production
133
+ - **Context-rich errors** – Debug information included in development
134
+
135
+ #### 📦 **Key Dependencies**
136
+
137
+ - Express.js web framework
138
+ - Zod for validation
139
+ - Structured logging system
140
+ - CORS middleware
141
+ - dotenv for environment variables
142
+
143
+ #### 🎯 **Design Philosophy**
144
+
145
+ - Never leak internal errors to clients in production
146
+ - Always classify errors (operational vs programmer)
147
+ - Consistent response format for all endpoints
148
+ - Type-safe validation with helpful error messages
149
+ - Easy to extend and maintain
150
+
151
+ ---
152
+
153
+ ## Versioning Scheme
154
+
155
+ Charcole follows [Semantic Versioning 2.0.0](https://semver.org/):
156
+
157
+ - **MAJOR** version for incompatible API changes
158
+ - **MINOR** version for new functionality (backwards compatible)
159
+ - **PATCH** version for bug fixes (backwards compatible)
160
+
161
+ ## Release Notes Policy
162
+
163
+ All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
164
+
165
+ ---
166
+
167
+ ## How to Update the Changelog
168
+
169
+ When creating a new release:
170
+
171
+ 1. Add a new `## [X.Y.Z]` header at the top of the file
172
+ 2. Use descriptive headings for each section
173
+ 3. Include migration notes if there are breaking changes
174
+ 4. Add emojis for visual clarity (optional but recommended)
175
+ 5. Update the "Unreleased" section if using one
176
+ 6. Include links to issues/PRs when relevant
177
+
178
+ ## Template for Future Releases
179
+
180
+ ```markdown
181
+ ## [X.Y.Z] – YYYY-MM-DD
182
+
183
+ ### ✨ Added
184
+
185
+ - New features or functionality
186
+
187
+ ### 🔧 Changed
188
+
189
+ - Changes to existing functionality
190
+
191
+ ### 🐛 Fixed
192
+
193
+ - Bug fixes
194
+
195
+ ### 🗑️ Removed
6
196
 
7
- - Full TypeScript project template support
8
- - Language selection (JavaScript / TypeScript) at CLI runtime
9
- - Improved project scaffolding structure
10
- - Better developer experience for production setups
197
+ - Features removed or deprecated
11
198
 
12
- ### Changed
199
+ ### 🚦 Migration Notes
13
200
 
14
- - Internal template resolution logic
15
- - CLI output and onboarding messages
201
+ - Instructions for upgrading from previous versions
16
202
 
17
- ### Fixed
203
+ ### ✅ Known Issues
18
204
 
19
- - Incorrect template path resolution in previous versions
20
- - Local CLI linking issues during development
205
+ - Any known bugs or limitations in this release
206
+ ```
21
207
 
22
- ### Notes
208
+ ---
23
209
 
24
- - This release focuses on stability and language parity.
25
- - Authentication and database modules are intentionally not included yet.
210
+ **Maintained by:** The Charcole Team
211
+ **Last Updated:** 2026-01-29