@intentsolutionsio/fullstack-starter-pack 1.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.
@@ -0,0 +1,338 @@
1
+ ---
2
+ name: env-config-setup
3
+ description: >
4
+ Generate environment configuration files and validation schemas
5
+ shortcut: ecs
6
+ category: devops
7
+ difficulty: beginner
8
+ estimated_time: 2-3 minutes
9
+ ---
10
+ # Environment Config Setup
11
+
12
+ Generates environment configuration files (.env templates, validation schemas, and type-safe config loading) for multiple environments.
13
+
14
+ ## What This Command Does
15
+
16
+ **Generated Configuration:**
17
+ - .env.example (committed template)
18
+ - .env.development, .env.production
19
+ - Config validation schema (Zod)
20
+ - Type-safe config loader
21
+ - Secret management guidance
22
+ - Docker environment setup
23
+
24
+ **Output:** Complete environment configuration system
25
+
26
+ **Time:** 2-3 minutes
27
+
28
+ ---
29
+
30
+ ## Usage
31
+
32
+ ```bash
33
+ # Generate basic environment config
34
+ /env-config-setup
35
+
36
+ # Shortcut
37
+ /ecs --services database,redis,email
38
+
39
+ # With specific platform
40
+ /ecs --platform aws --features secrets-manager
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Generated Files
46
+
47
+ ### **.env.example** (Template - Committed to Repo)
48
+
49
+ ```bash
50
+ # Application
51
+ NODE_ENV=development
52
+ PORT=3000
53
+ APP_NAME=My Application
54
+ APP_URL=http://localhost:3000
55
+
56
+ # Database
57
+ DATABASE_URL=postgresql://user:password@localhost:5432/myapp
58
+ DATABASE_POOL_MIN=2
59
+ DATABASE_POOL_MAX=10
60
+
61
+ # Redis
62
+ REDIS_URL=redis://localhost:6379
63
+ REDIS_PREFIX=myapp:
64
+
65
+ # Authentication
66
+ JWT_SECRET=generate-random-32-char-secret-here
67
+ JWT_EXPIRES_IN=15m
68
+ JWT_REFRESH_SECRET=generate-random-32-char-refresh-secret
69
+ JWT_REFRESH_EXPIRES_IN=7d
70
+
71
+ # Email (SendGrid)
72
+ SENDGRID_API_KEY=SG.your-api-key-here
73
+ FROM_EMAIL=[email protected]
74
+
75
+ # AWS (Optional)
76
+ AWS_ACCESS_KEY_ID=your-access-key
77
+ AWS_SECRET_ACCESS_KEY=your-secret-key
78
+ AWS_REGION=us-east-1
79
+ S3_BUCKET=your-bucket-name
80
+
81
+ # External APIs
82
+ STRIPE_SECRET_KEY=sk_test_your-stripe-key
83
+ STRIPE_WEBHOOK_SECRET=whsec_your-webhook-secret
84
+
85
+ # Monitoring
86
+ SENTRY_DSN=https://your-sentry-dsn
87
+ LOG_LEVEL=info
88
+
89
+ # Feature Flags
90
+ ENABLE_FEATURE_X=false
91
+ ```
92
+
93
+ ### **.env.development**
94
+
95
+ ```bash
96
+ NODE_ENV=development
97
+ PORT=3000
98
+ DATABASE_URL=postgresql://postgres:password@localhost:5432/myapp_dev
99
+ REDIS_URL=redis://localhost:6379
100
+ LOG_LEVEL=debug
101
+ ```
102
+
103
+ ### **.env.production**
104
+
105
+ ```bash
106
+ NODE_ENV=production
107
+ PORT=8080
108
+ # Use environment variables or secrets manager for sensitive values
109
+ DATABASE_URL=${DATABASE_URL}
110
+ REDIS_URL=${REDIS_URL}
111
+ JWT_SECRET=${JWT_SECRET}
112
+ LOG_LEVEL=warn
113
+ ```
114
+
115
+ ### **config/env.ts** (Type-Safe Config Loader)
116
+
117
+ ```typescript
118
+ import { z } from 'zod'
119
+ import dotenv from 'dotenv'
120
+
121
+ // Load appropriate .env file
122
+ const envFile = process.env.NODE_ENV === 'production'
123
+ ? '.env.production'
124
+ : '.env.development'
125
+
126
+ dotenv.config({ path: envFile })
127
+
128
+ // Define validation schema
129
+ const envSchema = z.object({
130
+ // Application
131
+ NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
132
+ PORT: z.coerce.number().min(1).max(65535).default(3000),
133
+ APP_NAME: z.string().min(1),
134
+ APP_URL: z.string().url(),
135
+
136
+ // Database
137
+ DATABASE_URL: z.string().url(),
138
+ DATABASE_POOL_MIN: z.coerce.number().min(0).default(2),
139
+ DATABASE_POOL_MAX: z.coerce.number().min(1).default(10),
140
+
141
+ // Redis
142
+ REDIS_URL: z.string().url(),
143
+ REDIS_PREFIX: z.string().default(''),
144
+
145
+ // Authentication
146
+ JWT_SECRET: z.string().min(32),
147
+ JWT_EXPIRES_IN: z.string().default('15m'),
148
+ JWT_REFRESH_SECRET: z.string().min(32),
149
+ JWT_REFRESH_EXPIRES_IN: z.string().default('7d'),
150
+
151
+ // Email
152
+ SENDGRID_API_KEY: z.string().startsWith('SG.'),
153
+ FROM_EMAIL: z.string().email(),
154
+
155
+ // AWS (optional)
156
+ AWS_ACCESS_KEY_ID: z.string().optional(),
157
+ AWS_SECRET_ACCESS_KEY: z.string().optional(),
158
+ AWS_REGION: z.string().default('us-east-1'),
159
+ S3_BUCKET: z.string().optional(),
160
+
161
+ // External APIs
162
+ STRIPE_SECRET_KEY: z.string().startsWith('sk_'),
163
+ STRIPE_WEBHOOK_SECRET: z.string().startsWith('whsec_'),
164
+
165
+ // Monitoring
166
+ SENTRY_DSN: z.string().url().optional(),
167
+ LOG_LEVEL: z.enum(['error', 'warn', 'info', 'debug']).default('info'),
168
+
169
+ // Feature Flags
170
+ ENABLE_FEATURE_X: z.coerce.boolean().default(false)
171
+ })
172
+
173
+ // Parse and validate
174
+ const parsedEnv = envSchema.safeParse(process.env)
175
+
176
+ if (!parsedEnv.success) {
177
+ console.error(' Invalid environment variables:')
178
+ console.error(parsedEnv.error.flatten().fieldErrors)
179
+ process.exit(1)
180
+ }
181
+
182
+ export const env = parsedEnv.data
183
+
184
+ // Type-safe access
185
+ export type Env = z.infer<typeof envSchema>
186
+ ```
187
+
188
+ ### **config/secrets.ts** (AWS Secrets Manager)
189
+
190
+ ```typescript
191
+ import { SecretsManager } from '@aws-sdk/client-secrets-manager'
192
+
193
+ const client = new SecretsManager({ region: process.env.AWS_REGION })
194
+
195
+ export async function loadSecrets(secretName: string) {
196
+ try {
197
+ const response = await client.getSecretValue({ SecretId: secretName })
198
+ return JSON.parse(response.SecretString || '{}')
199
+ } catch (error) {
200
+ console.error('Failed to load secrets:', error)
201
+ throw error
202
+ }
203
+ }
204
+
205
+ // Usage
206
+ const secrets = await loadSecrets('prod/myapp/secrets')
207
+ process.env.JWT_SECRET = secrets.JWT_SECRET
208
+ ```
209
+
210
+ ### **docker-compose.env.yml**
211
+
212
+ ```yaml
213
+ version: '3.8'
214
+
215
+ services:
216
+ app:
217
+ build: .
218
+ env_file:
219
+ - .env.development
220
+ environment:
221
+ - NODE_ENV=development
222
+ - PORT=3000
223
+ ports:
224
+ - "3000:3000"
225
+
226
+ db:
227
+ image: postgres:15-alpine
228
+ environment:
229
+ POSTGRES_USER: ${POSTGRES_USER:-postgres}
230
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
231
+ POSTGRES_DB: ${POSTGRES_DB:-myapp_dev}
232
+ ports:
233
+ - "5432:5432"
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Security Best Practices
239
+
240
+ **1. Never Commit Secrets:**
241
+ ```bash
242
+ # .gitignore
243
+ .env
244
+ .env.local
245
+ .env.*.local
246
+ .env.production
247
+ *.key
248
+ *.pem
249
+ secrets/
250
+ ```
251
+
252
+ **2. Use Secret Rotation:**
253
+ ```bash
254
+ # Rotate secrets regularly
255
+ # Use AWS Secrets Manager, GCP Secret Manager, or Azure Key Vault
256
+ # Example: Rotate JWT secrets every 30 days
257
+ ```
258
+
259
+ **3. Least Privilege:**
260
+ ```bash
261
+ # Only provide necessary permissions
262
+ # Use separate credentials for dev/staging/prod
263
+ # Implement role-based access control
264
+ ```
265
+
266
+ **4. Environment Validation:**
267
+ ```typescript
268
+ // Validate on startup
269
+ if (process.env.NODE_ENV === 'production') {
270
+ if (!env.JWT_SECRET || env.JWT_SECRET.length < 32) {
271
+ throw new Error('Production JWT_SECRET must be at least 32 characters')
272
+ }
273
+ }
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Secret Generation
279
+
280
+ ```bash
281
+ # Generate secure random secrets
282
+ node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
283
+
284
+ # Or use openssl
285
+ openssl rand -hex 32
286
+
287
+ # For JWT secrets (base64)
288
+ openssl rand -base64 32
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Platform-Specific Setup
294
+
295
+ **Vercel:**
296
+ ```bash
297
+ # Set environment variables via CLI
298
+ vercel env add DATABASE_URL production
299
+ vercel env add JWT_SECRET production
300
+ ```
301
+
302
+ **Railway:**
303
+ ```bash
304
+ # Environment variables in dashboard
305
+ # Or via railway.json
306
+ {
307
+ "deploy": {
308
+ "envVars": {
309
+ "NODE_ENV": "production"
310
+ }
311
+ }
312
+ }
313
+ ```
314
+
315
+ **AWS ECS:**
316
+ ```json
317
+ {
318
+ "containerDefinitions": [{
319
+ "secrets": [
320
+ {
321
+ "name": "DATABASE_URL",
322
+ "valueFrom": "arn:aws:secretsmanager:region:account:secret:name"
323
+ }
324
+ ]
325
+ }]
326
+ }
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Related Commands
332
+
333
+ - `/auth-setup` - Generate authentication system
334
+ - `/project-scaffold` - Generate full project structure
335
+
336
+ ---
337
+
338
+ **Manage secrets safely. Configure environments easily. Deploy confidently.** ️