@yoms/create-monorepo 1.2.0 → 4.0.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 (31) hide show
  1. package/README.md +132 -4
  2. package/dist/index.js +353 -65
  3. package/package.json +6 -2
  4. package/templates/backend-hono/base/{AGENT.md → CLAUDE.md} +42 -3
  5. package/templates/backend-hono/features/better-auth/env-additions.txt +4 -0
  6. package/templates/backend-hono/features/better-auth/package-additions.json +5 -0
  7. package/templates/backend-hono/features/better-auth/prisma/schema.prisma +69 -0
  8. package/templates/backend-hono/features/better-auth/src/config/env-auth.ts +8 -0
  9. package/templates/backend-hono/features/better-auth/src/index.ts +53 -0
  10. package/templates/backend-hono/features/better-auth/src/lib/auth.ts +21 -0
  11. package/templates/backend-hono/features/better-auth/src/middleware/auth.middleware.ts +38 -0
  12. package/templates/docker-compose.yml +70 -0
  13. package/templates/frontend-nextjs/base/CLAUDE.md +183 -0
  14. package/templates/frontend-nextjs/base/app/layout.tsx +4 -1
  15. package/templates/frontend-nextjs/base/components/examples/users-list-example.tsx +127 -0
  16. package/templates/frontend-nextjs/base/lib/auth-client.ts +18 -0
  17. package/templates/frontend-nextjs/base/package.json +4 -1
  18. package/templates/frontend-nextjs/base/providers/query-provider.tsx +28 -0
  19. package/templates/frontend-nextjs/base/services/README.md +184 -0
  20. package/templates/frontend-nextjs/base/{lib/api-client.ts → services/api/client.ts} +1 -0
  21. package/templates/frontend-nextjs/base/services/api/endpoints.ts +26 -0
  22. package/templates/frontend-nextjs/base/services/api/index.ts +6 -0
  23. package/templates/frontend-nextjs/base/services/auth/auth.hook.ts +61 -0
  24. package/templates/frontend-nextjs/base/services/auth/auth.types.ts +38 -0
  25. package/templates/frontend-nextjs/base/services/auth/index.ts +12 -0
  26. package/templates/frontend-nextjs/base/services/users/index.ts +8 -0
  27. package/templates/frontend-nextjs/base/services/users/users.hook.ts +119 -0
  28. package/templates/frontend-nextjs/base/services/users/users.queries.ts +14 -0
  29. package/templates/frontend-nextjs/base/services/users/users.service.ts +65 -0
  30. package/templates/frontend-nextjs/base/services/users/users.types.ts +37 -0
  31. package/templates/shared/base/CLAUDE.md +95 -0
package/README.md CHANGED
@@ -33,8 +33,10 @@ npm create @yoms/monorepo my-project
33
33
 
34
34
  ## Quick Start
35
35
 
36
+ ### Interactive Mode (Default)
37
+
36
38
  ```bash
37
- # Create a new project
39
+ # Create a new project with interactive prompts
38
40
  npx @yoms/create-monorepo my-project
39
41
 
40
42
  # Navigate to project
@@ -51,6 +53,49 @@ pnpm dev
51
53
  # - Frontend: http://localhost:3000
52
54
  ```
53
55
 
56
+ ### Non-Interactive Mode with CLI Flags
57
+
58
+ ```bash
59
+ # Create a project with all features using CLI flags
60
+ npx @yoms/create-monorepo my-project \
61
+ --backend hono \
62
+ --database postgres \
63
+ --redis \
64
+ --smtp \
65
+ --swagger \
66
+ --auth \
67
+ --frontend \
68
+ --shadcn \
69
+ --docker \
70
+ --pm pnpm
71
+
72
+ # Quick start with defaults (skips all prompts)
73
+ npx @yoms/create-monorepo my-project --yes
74
+ ```
75
+
76
+ ## CLI Options
77
+
78
+ ```bash
79
+ npx @yoms/create-monorepo [dir] [options]
80
+
81
+ Options:
82
+ --backend <framework> Backend framework (hono)
83
+ --database <db> Database (postgres, mongodb, none)
84
+ --redis Include Redis cache
85
+ --smtp Include SMTP email
86
+ --swagger Include Swagger docs
87
+ --auth Include JWT authentication
88
+ --frontend Include Next.js frontend
89
+ --shadcn Include shadcn/ui components
90
+ --pm <manager> Package manager (pnpm, npm, yarn, bun)
91
+ --docker Include Docker Compose setup
92
+ --skip-install Skip dependency installation
93
+ --skip-git Skip git initialization
94
+ -y, --yes Skip all prompts and use defaults
95
+ -h, --help Display help
96
+ -v, --version Display version
97
+ ```
98
+
54
99
  ## What You Get
55
100
 
56
101
  ### Backend Options
@@ -60,8 +105,12 @@ pnpm dev
60
105
  - **Caching**: Redis with ready-to-use cache service
61
106
  - **Email**: SMTP with Nodemailer
62
107
  - **Docs**: Swagger/OpenAPI with Scalar UI
108
+ - **Authentication**: JWT with refresh tokens (optional)
63
109
  - **Logging**: Winston with structured logging
64
110
  - **Validation**: Zod schemas
111
+ - **Error Handling**: Custom error classes and response helpers
112
+ - **Rate Limiting**: Memory-based rate limiter with presets
113
+ - **Testing**: Vitest with example tests
65
114
  - **Type Safety**: Full TypeScript with strict mode
66
115
 
67
116
  ### Frontend
@@ -85,12 +134,14 @@ my-project/
85
134
  │ ├── api/ # Backend API
86
135
  │ │ ├── src/
87
136
  │ │ │ ├── routes/ # API routes
88
- │ │ │ ├── middleware/ # Express/Hono middleware
137
+ │ │ │ ├── middleware/ # Hono middleware
89
138
  │ │ │ ├── services/ # Business logic
90
139
  │ │ │ ├── config/ # Configuration (env, logger, db)
140
+ │ │ │ ├── lib/ # Utilities (jwt, errors, response)
91
141
  │ │ │ └── types/ # TypeScript types
92
- │ │ ├── prisma/ # Database schema
93
- │ │ └── Dockerfile # Production container
142
+ │ │ ├── prisma/ # Database schema (if database selected)
143
+ │ │ ├── Dockerfile # Production container
144
+ │ │ └── vitest.config.ts # Test configuration
94
145
  │ │
95
146
  │ ├── web/ # Next.js frontend
96
147
  │ │ ├── app/ # App router pages
@@ -102,6 +153,7 @@ my-project/
102
153
  │ ├── schemas/ # Zod schemas
103
154
  │ └── types.ts # Common types
104
155
 
156
+ ├── docker-compose.yml # Docker services (if --docker)
105
157
  ├── pnpm-workspace.yaml # Workspace configuration
106
158
  └── tsconfig.base.json # Shared TypeScript config
107
159
  ```
@@ -157,6 +209,35 @@ SMTP_HOST=smtp.gmail.com
157
209
  SMTP_PORT=587
158
210
  SMTP_USER=...
159
211
  SMTP_PASS=...
212
+
213
+ # JWT (if --auth selected)
214
+ JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
215
+ JWT_EXPIRES_IN=15m
216
+ JWT_REFRESH_SECRET=your-super-secret-refresh-key-change-this-in-production
217
+ JWT_REFRESH_EXPIRES_IN=7d
218
+ ```
219
+
220
+ ## Docker Compose
221
+
222
+ When using the `--docker` flag, a `docker-compose.yml` file is generated with the following services based on your configuration:
223
+
224
+ - **PostgreSQL**: If `--database postgres` is selected
225
+ - **MongoDB**: If `--database mongodb` is selected
226
+ - **Redis**: If `--redis` is selected
227
+ - **MailHog**: If `--smtp` is selected (SMTP testing server with web UI)
228
+
229
+ ```bash
230
+ # Start all services
231
+ docker-compose up -d
232
+
233
+ # View logs
234
+ docker-compose logs -f
235
+
236
+ # Stop services
237
+ docker-compose down
238
+
239
+ # View MailHog web UI (if SMTP selected)
240
+ open http://localhost:8025
160
241
  ```
161
242
 
162
243
  ## Available Scripts
@@ -165,11 +246,16 @@ SMTP_PASS=...
165
246
  # Development
166
247
  pnpm dev # Start all packages in dev mode
167
248
  pnpm --filter api dev # Start only backend
249
+ pnpm --filter web dev # Start only frontend
168
250
 
169
251
  # Building
170
252
  pnpm build # Build all packages
171
253
  pnpm typecheck # Type-check all packages
172
254
 
255
+ # Testing
256
+ pnpm --filter api test # Run backend tests
257
+ pnpm --filter api test:watch # Run tests in watch mode
258
+
173
259
  # Database (if Prisma is selected)
174
260
  pnpm --filter api prisma:generate # Generate Prisma client
175
261
  pnpm --filter api prisma:migrate # Run migrations
@@ -180,6 +266,48 @@ pnpm lint # Lint all packages
180
266
  pnpm format # Format with Prettier
181
267
  ```
182
268
 
269
+ ## Authentication (JWT)
270
+
271
+ When using the `--auth` flag, JWT authentication is set up with the following features:
272
+
273
+ - **Access tokens**: Short-lived (15 minutes default)
274
+ - **Refresh tokens**: Long-lived (7 days default)
275
+ - **Password hashing**: bcryptjs with salt rounds
276
+ - **Protected routes**: Auth middleware for route protection
277
+
278
+ ### Example Usage
279
+
280
+ ```typescript
281
+ // Register a new user
282
+ POST /auth/register
283
+ {
284
+ "email": "user@example.com",
285
+ "password": "securepassword",
286
+ "name": "John Doe"
287
+ }
288
+
289
+ // Login
290
+ POST /auth/login
291
+ {
292
+ "email": "user@example.com",
293
+ "password": "securepassword"
294
+ }
295
+
296
+ // Refresh access token
297
+ POST /auth/refresh
298
+ {
299
+ "refreshToken": "..."
300
+ }
301
+
302
+ // Protected route example
303
+ import { authMiddleware } from './middleware/auth.middleware';
304
+
305
+ app.get('/protected', authMiddleware, (c) => {
306
+ const { userId, email } = c.get('jwtPayload');
307
+ return c.json({ userId, email });
308
+ });
309
+ ```
310
+
183
311
  ## Requirements
184
312
 
185
313
  - Node.js >= 18