@yoms/create-monorepo 1.0.2

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +204 -0
  3. package/dist/index.js +649 -0
  4. package/package.json +74 -0
  5. package/templates/backend-hono/base/.env.example +7 -0
  6. package/templates/backend-hono/base/Dockerfile +55 -0
  7. package/templates/backend-hono/base/package.json +30 -0
  8. package/templates/backend-hono/base/src/config/env.ts +12 -0
  9. package/templates/backend-hono/base/src/config/logger.ts +52 -0
  10. package/templates/backend-hono/base/src/index.ts +49 -0
  11. package/templates/backend-hono/base/src/lib/__tests__/response.test.ts +66 -0
  12. package/templates/backend-hono/base/src/lib/errors.ts +87 -0
  13. package/templates/backend-hono/base/src/lib/response.ts +72 -0
  14. package/templates/backend-hono/base/src/middleware/__tests__/error.test.ts +86 -0
  15. package/templates/backend-hono/base/src/middleware/cors.middleware.ts +9 -0
  16. package/templates/backend-hono/base/src/middleware/error.middleware.ts +43 -0
  17. package/templates/backend-hono/base/src/middleware/logger.middleware.ts +14 -0
  18. package/templates/backend-hono/base/src/middleware/rate-limit.middleware.ts +135 -0
  19. package/templates/backend-hono/base/src/routes/__tests__/health.test.ts +36 -0
  20. package/templates/backend-hono/base/src/routes/health.route.ts +14 -0
  21. package/templates/backend-hono/base/src/types/app.types.ts +26 -0
  22. package/templates/backend-hono/base/tsconfig.json +10 -0
  23. package/templates/backend-hono/base/vitest.config.ts +19 -0
  24. package/templates/backend-hono/features/mongodb-prisma/env-additions.txt +2 -0
  25. package/templates/backend-hono/features/mongodb-prisma/package-additions.json +14 -0
  26. package/templates/backend-hono/features/mongodb-prisma/prisma/schema.prisma +18 -0
  27. package/templates/backend-hono/features/mongodb-prisma/src/config/database.ts +43 -0
  28. package/templates/backend-hono/features/mongodb-prisma/src/routes/users.route.ts +82 -0
  29. package/templates/backend-hono/features/mongodb-prisma/src/services/user.service.ts +121 -0
  30. package/templates/backend-hono/features/postgres-prisma/env-additions.txt +2 -0
  31. package/templates/backend-hono/features/postgres-prisma/package-additions.json +15 -0
  32. package/templates/backend-hono/features/postgres-prisma/prisma/schema.prisma +18 -0
  33. package/templates/backend-hono/features/postgres-prisma/src/config/database.ts +43 -0
  34. package/templates/backend-hono/features/postgres-prisma/src/routes/users.route.ts +82 -0
  35. package/templates/backend-hono/features/postgres-prisma/src/services/user.service.ts +121 -0
  36. package/templates/backend-hono/features/redis/env-additions.txt +2 -0
  37. package/templates/backend-hono/features/redis/package-additions.json +8 -0
  38. package/templates/backend-hono/features/redis/src/config/redis.ts +32 -0
  39. package/templates/backend-hono/features/redis/src/services/cache.service.ts +107 -0
  40. package/templates/backend-hono/features/smtp/env-additions.txt +7 -0
  41. package/templates/backend-hono/features/smtp/package-additions.json +8 -0
  42. package/templates/backend-hono/features/smtp/src/config/mail.ts +38 -0
  43. package/templates/backend-hono/features/smtp/src/services/email.service.ts +78 -0
  44. package/templates/backend-hono/features/swagger/package-additions.json +6 -0
  45. package/templates/backend-hono/features/swagger/src/lib/openapi.ts +19 -0
  46. package/templates/backend-hono/features/swagger/src/routes/docs.route.ts +18 -0
  47. package/templates/frontend-nextjs/base/.env.example +2 -0
  48. package/templates/frontend-nextjs/base/app/globals.css +59 -0
  49. package/templates/frontend-nextjs/base/app/layout.tsx +22 -0
  50. package/templates/frontend-nextjs/base/app/page.tsx +49 -0
  51. package/templates/frontend-nextjs/base/components.json +18 -0
  52. package/templates/frontend-nextjs/base/lib/api-client.ts +67 -0
  53. package/templates/frontend-nextjs/base/lib/utils.ts +6 -0
  54. package/templates/frontend-nextjs/base/next.config.ts +8 -0
  55. package/templates/frontend-nextjs/base/package.json +33 -0
  56. package/templates/frontend-nextjs/base/postcss.config.mjs +9 -0
  57. package/templates/frontend-nextjs/base/public/.gitkeep +1 -0
  58. package/templates/frontend-nextjs/base/tailwind.config.ts +58 -0
  59. package/templates/frontend-nextjs/base/tsconfig.json +19 -0
  60. package/templates/shared/base/package.json +19 -0
  61. package/templates/shared/base/src/index.ts +5 -0
  62. package/templates/shared/base/src/schemas/user.schema.ts +34 -0
  63. package/templates/shared/base/src/types.ts +46 -0
  64. package/templates/shared/base/tsconfig.json +9 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 create-monorepo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # create-monorepo
2
+
3
+ [![npm version](https://badge.fury.io/js/create-monorepo.svg)](https://www.npmjs.com/package/create-monorepo)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A CLI tool to scaffold monorepo projects from templates with type sharing between packages.
7
+
8
+ ## Features
9
+
10
+ - 🚀 **Quick Setup** - Generate a fully-configured monorepo in minutes
11
+ - 📦 **Type Sharing** - Share Zod schemas and types between backend and frontend
12
+ - 🎯 **Best Practices** - Pre-configured with modern tooling and patterns
13
+ - 🔧 **Flexible** - Choose only the features you need
14
+ - 🐳 **Production Ready** - Includes Docker, logging, error handling
15
+
16
+ ## Installation
17
+
18
+ You don't need to install anything! Just run:
19
+
20
+ ```bash
21
+ # Using npx (recommended)
22
+ npx create-monorepo my-project
23
+
24
+ # Using pnpm
25
+ pnpm create monorepo my-project
26
+
27
+ # Using yarn
28
+ yarn create monorepo my-project
29
+
30
+ # Using bun
31
+ bunx create-monorepo my-project
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```bash
37
+ # Create a new project
38
+ npx create-monorepo my-project
39
+
40
+ # Navigate to project
41
+ cd my-project
42
+
43
+ # Install dependencies
44
+ pnpm install
45
+
46
+ # Start development
47
+ pnpm dev
48
+
49
+ # Visit:
50
+ # - Backend API: http://localhost:3001
51
+ # - Frontend: http://localhost:3000
52
+ ```
53
+
54
+ ## What You Get
55
+
56
+ ### Backend Options
57
+
58
+ - **Framework**: Hono (recommended) or TSOA
59
+ - **Database**: PostgreSQL or MongoDB with Prisma
60
+ - **Caching**: Redis with ready-to-use cache service
61
+ - **Email**: SMTP with Nodemailer
62
+ - **Docs**: Swagger/OpenAPI with Scalar UI
63
+ - **Logging**: Winston with structured logging
64
+ - **Validation**: Zod schemas
65
+ - **Type Safety**: Full TypeScript with strict mode
66
+
67
+ ### Frontend
68
+
69
+ - **Framework**: Next.js 15 with App Router
70
+ - **UI**: shadcn/ui components (optional)
71
+ - **Styling**: Tailwind CSS
72
+ - **Type Safety**: Shared types from backend
73
+
74
+ ### Shared Package
75
+
76
+ - **Zod Schemas**: Single source of truth for validation and types
77
+ - **Common Types**: Result, ApiResponse, Pagination, etc.
78
+ - **Type Sharing**: Import types directly in backend and frontend
79
+
80
+ ## Project Structure
81
+
82
+ ```
83
+ my-project/
84
+ ├── packages/
85
+ │ ├── api/ # Backend API
86
+ │ │ ├── src/
87
+ │ │ │ ├── routes/ # API routes
88
+ │ │ │ ├── middleware/ # Express/Hono middleware
89
+ │ │ │ ├── services/ # Business logic
90
+ │ │ │ ├── config/ # Configuration (env, logger, db)
91
+ │ │ │ └── types/ # TypeScript types
92
+ │ │ ├── prisma/ # Database schema
93
+ │ │ └── Dockerfile # Production container
94
+ │ │
95
+ │ ├── web/ # Next.js frontend
96
+ │ │ ├── app/ # App router pages
97
+ │ │ ├── components/ # React components
98
+ │ │ └── lib/ # Utilities and API client
99
+ │ │
100
+ │ └── shared/ # Shared types and schemas
101
+ │ └── src/
102
+ │ ├── schemas/ # Zod schemas
103
+ │ └── types.ts # Common types
104
+
105
+ ├── pnpm-workspace.yaml # Workspace configuration
106
+ └── tsconfig.base.json # Shared TypeScript config
107
+ ```
108
+
109
+ ## Templates
110
+
111
+ ### Hono Backend
112
+
113
+ - **Runtime-agnostic**: Works on Node, Bun, Deno, Cloudflare Workers
114
+ - **Best TypeScript inference**: Type-safe without code generation
115
+ - **Lightweight**: 12KB bundle, ~4x faster than Express
116
+ - **Modern API**: Chainable, intuitive routing
117
+ - **Built-in middleware**: CORS, compression, JWT, etc.
118
+
119
+ ### Type Sharing Pattern
120
+
121
+ ```typescript
122
+ // packages/shared/src/schemas/user.schema.ts
123
+ export const UserSchema = z.object({
124
+ id: z.string(),
125
+ email: z.string().email(),
126
+ name: z.string(),
127
+ });
128
+ export type User = z.infer<typeof UserSchema>;
129
+
130
+ // packages/api/src/routes/users.ts
131
+ import { UserSchema } from '@my-project/shared';
132
+ // Use for validation and type inference
133
+
134
+ // packages/web/lib/api.ts
135
+ import type { User } from '@my-project/shared';
136
+ // Use for type-safe API calls
137
+ ```
138
+
139
+ ## Configuration
140
+
141
+ All configuration is done via environment variables (12-factor app):
142
+
143
+ ```env
144
+ # Server
145
+ NODE_ENV=development
146
+ PORT=3001
147
+ LOG_LEVEL=info
148
+
149
+ # Database (if selected)
150
+ DATABASE_URL=postgresql://...
151
+
152
+ # Redis (if selected)
153
+ REDIS_URL=redis://localhost:6379
154
+
155
+ # SMTP (if selected)
156
+ SMTP_HOST=smtp.gmail.com
157
+ SMTP_PORT=587
158
+ SMTP_USER=...
159
+ SMTP_PASS=...
160
+ ```
161
+
162
+ ## Available Scripts
163
+
164
+ ```bash
165
+ # Development
166
+ pnpm dev # Start all packages in dev mode
167
+ pnpm --filter api dev # Start only backend
168
+
169
+ # Building
170
+ pnpm build # Build all packages
171
+ pnpm typecheck # Type-check all packages
172
+
173
+ # Database (if Prisma is selected)
174
+ pnpm --filter api prisma:generate # Generate Prisma client
175
+ pnpm --filter api prisma:migrate # Run migrations
176
+ pnpm --filter api prisma:studio # Open Prisma Studio
177
+
178
+ # Code quality
179
+ pnpm lint # Lint all packages
180
+ pnpm format # Format with Prettier
181
+ ```
182
+
183
+ ## Requirements
184
+
185
+ - Node.js >= 18
186
+ - pnpm, npm, yarn, or bun
187
+
188
+ ## Contributing
189
+
190
+ Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details.
191
+
192
+ ## Changelog
193
+
194
+ See [CHANGELOG.md](CHANGELOG.md) for a history of changes.
195
+
196
+ ## Support
197
+
198
+ - 📖 [Documentation](https://github.com/yoms07/monorepo-template)
199
+ - 🐛 [Issue Tracker](https://github.com/yoms07/monorepo-template/issues)
200
+ - 💬 [Discussions](https://github.com/yoms07/monorepo-template/discussions)
201
+
202
+ ## License
203
+
204
+ MIT © [yoms07](https://github.com/yoms07)