servcraft 0.1.0 → 0.1.1

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 (216) hide show
  1. package/.claude/settings.local.json +29 -0
  2. package/.github/CODEOWNERS +18 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +46 -0
  4. package/.github/dependabot.yml +59 -0
  5. package/.github/workflows/ci.yml +188 -0
  6. package/.github/workflows/release.yml +195 -0
  7. package/AUDIT.md +602 -0
  8. package/README.md +1070 -1
  9. package/dist/cli/index.cjs +2026 -2168
  10. package/dist/cli/index.cjs.map +1 -1
  11. package/dist/cli/index.js +2026 -2168
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/index.cjs +595 -616
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +114 -52
  16. package/dist/index.d.ts +114 -52
  17. package/dist/index.js +595 -616
  18. package/dist/index.js.map +1 -1
  19. package/docs/CLI-001_MULTI_DB_PLAN.md +546 -0
  20. package/docs/DATABASE_MULTI_ORM.md +399 -0
  21. package/docs/PHASE1_BREAKDOWN.md +346 -0
  22. package/docs/PROGRESS.md +550 -0
  23. package/docs/modules/ANALYTICS.md +226 -0
  24. package/docs/modules/API-VERSIONING.md +252 -0
  25. package/docs/modules/AUDIT.md +192 -0
  26. package/docs/modules/AUTH.md +431 -0
  27. package/docs/modules/CACHE.md +346 -0
  28. package/docs/modules/EMAIL.md +254 -0
  29. package/docs/modules/FEATURE-FLAG.md +291 -0
  30. package/docs/modules/I18N.md +294 -0
  31. package/docs/modules/MEDIA-PROCESSING.md +281 -0
  32. package/docs/modules/MFA.md +266 -0
  33. package/docs/modules/NOTIFICATION.md +311 -0
  34. package/docs/modules/OAUTH.md +237 -0
  35. package/docs/modules/PAYMENT.md +804 -0
  36. package/docs/modules/QUEUE.md +540 -0
  37. package/docs/modules/RATE-LIMIT.md +339 -0
  38. package/docs/modules/SEARCH.md +288 -0
  39. package/docs/modules/SECURITY.md +327 -0
  40. package/docs/modules/SESSION.md +382 -0
  41. package/docs/modules/SWAGGER.md +305 -0
  42. package/docs/modules/UPLOAD.md +296 -0
  43. package/docs/modules/USER.md +505 -0
  44. package/docs/modules/VALIDATION.md +294 -0
  45. package/docs/modules/WEBHOOK.md +270 -0
  46. package/docs/modules/WEBSOCKET.md +691 -0
  47. package/package.json +53 -38
  48. package/prisma/schema.prisma +395 -1
  49. package/src/cli/commands/add-module.ts +520 -87
  50. package/src/cli/commands/db.ts +3 -4
  51. package/src/cli/commands/docs.ts +256 -6
  52. package/src/cli/commands/generate.ts +12 -19
  53. package/src/cli/commands/init.ts +384 -214
  54. package/src/cli/index.ts +0 -4
  55. package/src/cli/templates/repository.ts +6 -1
  56. package/src/cli/templates/routes.ts +6 -21
  57. package/src/cli/utils/docs-generator.ts +6 -7
  58. package/src/cli/utils/env-manager.ts +717 -0
  59. package/src/cli/utils/field-parser.ts +16 -7
  60. package/src/cli/utils/interactive-prompt.ts +223 -0
  61. package/src/cli/utils/template-manager.ts +346 -0
  62. package/src/config/database.config.ts +183 -0
  63. package/src/config/env.ts +0 -10
  64. package/src/config/index.ts +0 -14
  65. package/src/core/server.ts +1 -1
  66. package/src/database/adapters/mongoose.adapter.ts +132 -0
  67. package/src/database/adapters/prisma.adapter.ts +118 -0
  68. package/src/database/connection.ts +190 -0
  69. package/src/database/interfaces/database.interface.ts +85 -0
  70. package/src/database/interfaces/index.ts +7 -0
  71. package/src/database/interfaces/repository.interface.ts +129 -0
  72. package/src/database/models/mongoose/index.ts +7 -0
  73. package/src/database/models/mongoose/payment.schema.ts +347 -0
  74. package/src/database/models/mongoose/user.schema.ts +154 -0
  75. package/src/database/prisma.ts +1 -4
  76. package/src/database/redis.ts +101 -0
  77. package/src/database/repositories/mongoose/index.ts +7 -0
  78. package/src/database/repositories/mongoose/payment.repository.ts +380 -0
  79. package/src/database/repositories/mongoose/user.repository.ts +255 -0
  80. package/src/database/seed.ts +6 -1
  81. package/src/index.ts +9 -20
  82. package/src/middleware/security.ts +2 -6
  83. package/src/modules/analytics/analytics.routes.ts +80 -0
  84. package/src/modules/analytics/analytics.service.ts +364 -0
  85. package/src/modules/analytics/index.ts +18 -0
  86. package/src/modules/analytics/types.ts +180 -0
  87. package/src/modules/api-versioning/index.ts +15 -0
  88. package/src/modules/api-versioning/types.ts +86 -0
  89. package/src/modules/api-versioning/versioning.middleware.ts +120 -0
  90. package/src/modules/api-versioning/versioning.routes.ts +54 -0
  91. package/src/modules/api-versioning/versioning.service.ts +189 -0
  92. package/src/modules/audit/audit.repository.ts +206 -0
  93. package/src/modules/audit/audit.service.ts +27 -59
  94. package/src/modules/auth/auth.controller.ts +2 -2
  95. package/src/modules/auth/auth.middleware.ts +3 -9
  96. package/src/modules/auth/auth.routes.ts +10 -107
  97. package/src/modules/auth/auth.service.ts +126 -23
  98. package/src/modules/auth/index.ts +3 -4
  99. package/src/modules/cache/cache.service.ts +367 -0
  100. package/src/modules/cache/index.ts +10 -0
  101. package/src/modules/cache/types.ts +44 -0
  102. package/src/modules/email/email.service.ts +3 -10
  103. package/src/modules/email/templates.ts +2 -8
  104. package/src/modules/feature-flag/feature-flag.repository.ts +303 -0
  105. package/src/modules/feature-flag/feature-flag.routes.ts +247 -0
  106. package/src/modules/feature-flag/feature-flag.service.ts +566 -0
  107. package/src/modules/feature-flag/index.ts +20 -0
  108. package/src/modules/feature-flag/types.ts +192 -0
  109. package/src/modules/i18n/i18n.middleware.ts +186 -0
  110. package/src/modules/i18n/i18n.routes.ts +191 -0
  111. package/src/modules/i18n/i18n.service.ts +456 -0
  112. package/src/modules/i18n/index.ts +18 -0
  113. package/src/modules/i18n/types.ts +118 -0
  114. package/src/modules/media-processing/index.ts +17 -0
  115. package/src/modules/media-processing/media-processing.routes.ts +111 -0
  116. package/src/modules/media-processing/media-processing.service.ts +245 -0
  117. package/src/modules/media-processing/types.ts +156 -0
  118. package/src/modules/mfa/index.ts +20 -0
  119. package/src/modules/mfa/mfa.repository.ts +206 -0
  120. package/src/modules/mfa/mfa.routes.ts +595 -0
  121. package/src/modules/mfa/mfa.service.ts +572 -0
  122. package/src/modules/mfa/totp.ts +150 -0
  123. package/src/modules/mfa/types.ts +57 -0
  124. package/src/modules/notification/index.ts +20 -0
  125. package/src/modules/notification/notification.repository.ts +356 -0
  126. package/src/modules/notification/notification.service.ts +483 -0
  127. package/src/modules/notification/types.ts +119 -0
  128. package/src/modules/oauth/index.ts +20 -0
  129. package/src/modules/oauth/oauth.repository.ts +219 -0
  130. package/src/modules/oauth/oauth.routes.ts +446 -0
  131. package/src/modules/oauth/oauth.service.ts +293 -0
  132. package/src/modules/oauth/providers/apple.provider.ts +250 -0
  133. package/src/modules/oauth/providers/facebook.provider.ts +181 -0
  134. package/src/modules/oauth/providers/github.provider.ts +248 -0
  135. package/src/modules/oauth/providers/google.provider.ts +189 -0
  136. package/src/modules/oauth/providers/twitter.provider.ts +214 -0
  137. package/src/modules/oauth/types.ts +94 -0
  138. package/src/modules/payment/index.ts +19 -0
  139. package/src/modules/payment/payment.repository.ts +733 -0
  140. package/src/modules/payment/payment.routes.ts +390 -0
  141. package/src/modules/payment/payment.service.ts +354 -0
  142. package/src/modules/payment/providers/mobile-money.provider.ts +274 -0
  143. package/src/modules/payment/providers/paypal.provider.ts +190 -0
  144. package/src/modules/payment/providers/stripe.provider.ts +215 -0
  145. package/src/modules/payment/types.ts +140 -0
  146. package/src/modules/queue/cron.ts +438 -0
  147. package/src/modules/queue/index.ts +87 -0
  148. package/src/modules/queue/queue.routes.ts +600 -0
  149. package/src/modules/queue/queue.service.ts +842 -0
  150. package/src/modules/queue/types.ts +222 -0
  151. package/src/modules/queue/workers.ts +366 -0
  152. package/src/modules/rate-limit/index.ts +59 -0
  153. package/src/modules/rate-limit/rate-limit.middleware.ts +134 -0
  154. package/src/modules/rate-limit/rate-limit.routes.ts +269 -0
  155. package/src/modules/rate-limit/rate-limit.service.ts +348 -0
  156. package/src/modules/rate-limit/stores/memory.store.ts +165 -0
  157. package/src/modules/rate-limit/stores/redis.store.ts +322 -0
  158. package/src/modules/rate-limit/types.ts +153 -0
  159. package/src/modules/search/adapters/elasticsearch.adapter.ts +326 -0
  160. package/src/modules/search/adapters/meilisearch.adapter.ts +261 -0
  161. package/src/modules/search/adapters/memory.adapter.ts +278 -0
  162. package/src/modules/search/index.ts +21 -0
  163. package/src/modules/search/search.service.ts +234 -0
  164. package/src/modules/search/types.ts +214 -0
  165. package/src/modules/security/index.ts +40 -0
  166. package/src/modules/security/sanitize.ts +223 -0
  167. package/src/modules/security/security-audit.service.ts +388 -0
  168. package/src/modules/security/security.middleware.ts +398 -0
  169. package/src/modules/session/index.ts +3 -0
  170. package/src/modules/session/session.repository.ts +159 -0
  171. package/src/modules/session/session.service.ts +340 -0
  172. package/src/modules/session/types.ts +38 -0
  173. package/src/modules/swagger/index.ts +7 -1
  174. package/src/modules/swagger/schema-builder.ts +16 -4
  175. package/src/modules/swagger/swagger.service.ts +9 -10
  176. package/src/modules/swagger/types.ts +0 -2
  177. package/src/modules/upload/index.ts +14 -0
  178. package/src/modules/upload/types.ts +83 -0
  179. package/src/modules/upload/upload.repository.ts +199 -0
  180. package/src/modules/upload/upload.routes.ts +311 -0
  181. package/src/modules/upload/upload.service.ts +448 -0
  182. package/src/modules/user/index.ts +3 -3
  183. package/src/modules/user/user.controller.ts +15 -9
  184. package/src/modules/user/user.repository.ts +237 -113
  185. package/src/modules/user/user.routes.ts +39 -164
  186. package/src/modules/user/user.service.ts +4 -3
  187. package/src/modules/validation/validator.ts +12 -17
  188. package/src/modules/webhook/index.ts +91 -0
  189. package/src/modules/webhook/retry.ts +196 -0
  190. package/src/modules/webhook/signature.ts +135 -0
  191. package/src/modules/webhook/types.ts +181 -0
  192. package/src/modules/webhook/webhook.repository.ts +358 -0
  193. package/src/modules/webhook/webhook.routes.ts +442 -0
  194. package/src/modules/webhook/webhook.service.ts +457 -0
  195. package/src/modules/websocket/features.ts +504 -0
  196. package/src/modules/websocket/index.ts +106 -0
  197. package/src/modules/websocket/middlewares.ts +298 -0
  198. package/src/modules/websocket/types.ts +181 -0
  199. package/src/modules/websocket/websocket.service.ts +692 -0
  200. package/src/utils/errors.ts +7 -0
  201. package/src/utils/pagination.ts +4 -1
  202. package/tests/helpers/db-check.ts +79 -0
  203. package/tests/integration/auth-redis.test.ts +94 -0
  204. package/tests/integration/cache-redis.test.ts +387 -0
  205. package/tests/integration/mongoose-repositories.test.ts +410 -0
  206. package/tests/integration/payment-prisma.test.ts +637 -0
  207. package/tests/integration/queue-bullmq.test.ts +417 -0
  208. package/tests/integration/user-prisma.test.ts +441 -0
  209. package/tests/integration/websocket-socketio.test.ts +552 -0
  210. package/tests/setup.ts +11 -9
  211. package/vitest.config.ts +3 -8
  212. package/npm-cache/_cacache/content-v2/sha512/1c/d0/03440d500a0487621aad1d6402978340698976602046db8e24fa03c01ee6c022c69b0582f969042d9442ee876ac35c038e960dd427d1e622fa24b8eb7dba +0 -0
  213. package/npm-cache/_cacache/content-v2/sha512/42/55/28b493ca491833e5aab0e9c3108d29ab3f36c248ca88f45d4630674fce9130959e56ae308797ac2b6328fa7f09a610b9550ed09cb971d039876d293fc69d +0 -0
  214. package/npm-cache/_cacache/content-v2/sha512/e0/12/f360dc9315ee5f17844a0c8c233ee6bf7c30837c4a02ea0d56c61c7f7ab21c0e958e50ed2c57c59f983c762b93056778c9009b2398ffc26def0183999b13 +0 -0
  215. package/npm-cache/_cacache/content-v2/sha512/ed/b0/fae1161902898f4c913c67d7f6cdf6be0665aec3b389b9c4f4f0a101ca1da59badf1b59c4e0030f5223023b8d63cfe501c46a32c20c895d4fb3f11ca2232 +0 -0
  216. package/npm-cache/_cacache/index-v5/58/94/c2cba79e0f16b4c10e95a87e32255741149e8222cc314a476aab67c39cc0 +0 -5
@@ -0,0 +1,717 @@
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
3
+ import { existsSync } from 'fs';
4
+
5
+ export interface EnvVariable {
6
+ key: string;
7
+ value?: string;
8
+ comment?: string;
9
+ required?: boolean;
10
+ }
11
+
12
+ export interface EnvSection {
13
+ title: string;
14
+ variables: EnvVariable[];
15
+ }
16
+
17
+ /**
18
+ * Environment Manager
19
+ * Manages .env file updates when adding modules
20
+ */
21
+ export class EnvManager {
22
+ private envPath: string;
23
+ private envExamplePath: string;
24
+
25
+ constructor(projectRoot: string) {
26
+ this.envPath = path.join(projectRoot, '.env');
27
+ this.envExamplePath = path.join(projectRoot, '.env.example');
28
+ }
29
+
30
+ /**
31
+ * Add environment variables to .env file
32
+ */
33
+ async addVariables(sections: EnvSection[]): Promise<{
34
+ added: string[];
35
+ skipped: string[];
36
+ created: boolean;
37
+ }> {
38
+ const added: string[] = [];
39
+ const skipped: string[] = [];
40
+ let created = false;
41
+
42
+ // Read existing .env or create new one
43
+ let envContent = '';
44
+ if (existsSync(this.envPath)) {
45
+ envContent = await fs.readFile(this.envPath, 'utf-8');
46
+ } else {
47
+ created = true;
48
+ }
49
+
50
+ // Parse existing variables
51
+ const existingKeys = this.parseExistingKeys(envContent);
52
+
53
+ // Build new content
54
+ let newContent = envContent;
55
+ if (newContent && !newContent.endsWith('\n\n')) {
56
+ newContent += '\n\n';
57
+ }
58
+
59
+ for (const section of sections) {
60
+ // Add section comment
61
+ newContent += `# ${section.title}\n`;
62
+
63
+ for (const variable of section.variables) {
64
+ // Skip if already exists
65
+ if (existingKeys.has(variable.key)) {
66
+ skipped.push(variable.key);
67
+ continue;
68
+ }
69
+
70
+ // Add variable comment if provided
71
+ if (variable.comment) {
72
+ newContent += `# ${variable.comment}\n`;
73
+ }
74
+
75
+ // Add variable
76
+ const value = variable.value || '';
77
+ const prefix = variable.required ? '' : '# ';
78
+ newContent += `${prefix}${variable.key}=${value}\n`;
79
+
80
+ added.push(variable.key);
81
+ }
82
+
83
+ newContent += '\n';
84
+ }
85
+
86
+ // Write to .env
87
+ await fs.writeFile(this.envPath, newContent, 'utf-8');
88
+
89
+ // Update .env.example if it exists
90
+ if (existsSync(this.envExamplePath)) {
91
+ await this.updateEnvExample(sections);
92
+ }
93
+
94
+ return { added, skipped, created };
95
+ }
96
+
97
+ /**
98
+ * Update .env.example file
99
+ */
100
+ private async updateEnvExample(sections: EnvSection[]): Promise<void> {
101
+ let exampleContent = '';
102
+ if (existsSync(this.envExamplePath)) {
103
+ exampleContent = await fs.readFile(this.envExamplePath, 'utf-8');
104
+ }
105
+
106
+ const existingKeys = this.parseExistingKeys(exampleContent);
107
+
108
+ let newContent = exampleContent;
109
+ if (newContent && !newContent.endsWith('\n\n')) {
110
+ newContent += '\n\n';
111
+ }
112
+
113
+ for (const section of sections) {
114
+ newContent += `# ${section.title}\n`;
115
+
116
+ for (const variable of section.variables) {
117
+ if (existingKeys.has(variable.key)) {
118
+ continue;
119
+ }
120
+
121
+ if (variable.comment) {
122
+ newContent += `# ${variable.comment}\n`;
123
+ }
124
+
125
+ // In .env.example, show placeholder values
126
+ const placeholder = this.getPlaceholder(variable.key);
127
+ newContent += `${variable.key}=${placeholder}\n`;
128
+ }
129
+
130
+ newContent += '\n';
131
+ }
132
+
133
+ await fs.writeFile(this.envExamplePath, newContent, 'utf-8');
134
+ }
135
+
136
+ /**
137
+ * Parse existing environment variable keys
138
+ */
139
+ private parseExistingKeys(content: string): Set<string> {
140
+ const keys = new Set<string>();
141
+ const lines = content.split('\n');
142
+
143
+ for (const line of lines) {
144
+ const trimmed = line.trim();
145
+
146
+ // Skip comments and empty lines
147
+ if (!trimmed || trimmed.startsWith('#')) {
148
+ continue;
149
+ }
150
+
151
+ // Extract key from KEY=value or # KEY=value
152
+ const match = trimmed.match(/^#?\s*([A-Z_][A-Z0-9_]*)\s*=/);
153
+ if (match && match[1]) {
154
+ keys.add(match[1]);
155
+ }
156
+ }
157
+
158
+ return keys;
159
+ }
160
+
161
+ /**
162
+ * Get placeholder value for .env.example
163
+ */
164
+ private getPlaceholder(key: string): string {
165
+ // Common patterns
166
+ if (key.includes('SECRET') || key.includes('KEY') || key.includes('PASSWORD')) {
167
+ return 'your-secret-key-here';
168
+ }
169
+ if (key.includes('HOST')) {
170
+ return 'localhost';
171
+ }
172
+ if (key.includes('PORT')) {
173
+ return '3000';
174
+ }
175
+ if (key.includes('URL')) {
176
+ return 'http://localhost:3000';
177
+ }
178
+ if (key.includes('EMAIL')) {
179
+ return 'user@example.com';
180
+ }
181
+ if (key.includes('REDIS')) {
182
+ return 'redis://localhost:6379';
183
+ }
184
+ if (key.includes('DATABASE')) {
185
+ return 'postgresql://user:pass@localhost:5432/db';
186
+ }
187
+ if (key.includes('NODE')) {
188
+ return 'http://localhost:9200';
189
+ }
190
+
191
+ return '';
192
+ }
193
+
194
+ /**
195
+ * Get environment variables for a specific module
196
+ */
197
+ static getModuleEnvVariables(moduleName: string): EnvSection[] {
198
+ const moduleEnvMap: Record<string, EnvSection[]> = {
199
+ 'rate-limit': [
200
+ {
201
+ title: 'Rate Limiting Configuration',
202
+ variables: [
203
+ {
204
+ key: 'RATE_LIMIT_ENABLED',
205
+ value: 'true',
206
+ comment: 'Enable rate limiting',
207
+ required: true,
208
+ },
209
+ {
210
+ key: 'RATE_LIMIT_REDIS_URL',
211
+ value: 'redis://localhost:6379',
212
+ comment:
213
+ 'Redis URL for distributed rate limiting (optional, uses in-memory if not set)',
214
+ required: false,
215
+ },
216
+ ],
217
+ },
218
+ ],
219
+ webhook: [
220
+ {
221
+ title: 'Webhook Configuration',
222
+ variables: [
223
+ {
224
+ key: 'WEBHOOK_TIMEOUT',
225
+ value: '10000',
226
+ comment: 'Webhook request timeout in milliseconds',
227
+ required: true,
228
+ },
229
+ {
230
+ key: 'WEBHOOK_MAX_RETRIES',
231
+ value: '5',
232
+ comment: 'Maximum number of retry attempts',
233
+ required: true,
234
+ },
235
+ {
236
+ key: 'WEBHOOK_SIGNATURE_ENABLED',
237
+ value: 'true',
238
+ comment: 'Enable HMAC signature verification',
239
+ required: true,
240
+ },
241
+ ],
242
+ },
243
+ ],
244
+ queue: [
245
+ {
246
+ title: 'Queue/Jobs Configuration',
247
+ variables: [
248
+ {
249
+ key: 'REDIS_HOST',
250
+ value: 'localhost',
251
+ comment: 'Redis host for Bull queue',
252
+ required: true,
253
+ },
254
+ {
255
+ key: 'REDIS_PORT',
256
+ value: '6379',
257
+ comment: 'Redis port',
258
+ required: true,
259
+ },
260
+ {
261
+ key: 'REDIS_PASSWORD',
262
+ value: '',
263
+ comment: 'Redis password (optional)',
264
+ required: false,
265
+ },
266
+ {
267
+ key: 'QUEUE_METRICS_ENABLED',
268
+ value: 'true',
269
+ comment: 'Enable queue metrics collection',
270
+ required: true,
271
+ },
272
+ ],
273
+ },
274
+ ],
275
+ websocket: [
276
+ {
277
+ title: 'WebSocket Configuration',
278
+ variables: [
279
+ {
280
+ key: 'WEBSOCKET_PORT',
281
+ value: '3001',
282
+ comment: 'WebSocket server port',
283
+ required: true,
284
+ },
285
+ {
286
+ key: 'WEBSOCKET_CORS_ORIGIN',
287
+ value: 'http://localhost:3000',
288
+ comment: 'CORS origin for WebSocket',
289
+ required: true,
290
+ },
291
+ {
292
+ key: 'WEBSOCKET_REDIS_URL',
293
+ value: 'redis://localhost:6379',
294
+ comment: 'Redis URL for Socket.io adapter (optional, for multi-instance)',
295
+ required: false,
296
+ },
297
+ ],
298
+ },
299
+ ],
300
+ search: [
301
+ {
302
+ title: 'Search Configuration (Elasticsearch)',
303
+ variables: [
304
+ {
305
+ key: 'SEARCH_ENGINE',
306
+ value: 'memory',
307
+ comment: 'Search engine: elasticsearch, meilisearch, or memory',
308
+ required: true,
309
+ },
310
+ {
311
+ key: 'ELASTICSEARCH_NODE',
312
+ value: 'http://localhost:9200',
313
+ comment: 'Elasticsearch node URL',
314
+ required: false,
315
+ },
316
+ {
317
+ key: 'ELASTICSEARCH_USERNAME',
318
+ value: '',
319
+ comment: 'Elasticsearch username (optional)',
320
+ required: false,
321
+ },
322
+ {
323
+ key: 'ELASTICSEARCH_PASSWORD',
324
+ value: '',
325
+ comment: 'Elasticsearch password (optional)',
326
+ required: false,
327
+ },
328
+ ],
329
+ },
330
+ {
331
+ title: 'Search Configuration (Meilisearch)',
332
+ variables: [
333
+ {
334
+ key: 'MEILISEARCH_HOST',
335
+ value: 'http://localhost:7700',
336
+ comment: 'Meilisearch host URL',
337
+ required: false,
338
+ },
339
+ {
340
+ key: 'MEILISEARCH_API_KEY',
341
+ value: '',
342
+ comment: 'Meilisearch API key (optional)',
343
+ required: false,
344
+ },
345
+ ],
346
+ },
347
+ ],
348
+ i18n: [
349
+ {
350
+ title: 'i18n/Localization Configuration',
351
+ variables: [
352
+ {
353
+ key: 'DEFAULT_LOCALE',
354
+ value: 'en',
355
+ comment: 'Default locale/language',
356
+ required: true,
357
+ },
358
+ {
359
+ key: 'SUPPORTED_LOCALES',
360
+ value: 'en,fr,es,de,ar,zh,ja',
361
+ comment: 'Comma-separated list of supported locales',
362
+ required: true,
363
+ },
364
+ {
365
+ key: 'TRANSLATIONS_DIR',
366
+ value: './locales',
367
+ comment: 'Directory for translation files',
368
+ required: true,
369
+ },
370
+ {
371
+ key: 'I18N_CACHE_ENABLED',
372
+ value: 'true',
373
+ comment: 'Enable translation caching',
374
+ required: true,
375
+ },
376
+ ],
377
+ },
378
+ ],
379
+ cache: [
380
+ {
381
+ title: 'Cache Configuration',
382
+ variables: [
383
+ {
384
+ key: 'CACHE_PROVIDER',
385
+ value: 'redis',
386
+ comment: 'Cache provider: redis or memory',
387
+ required: true,
388
+ },
389
+ {
390
+ key: 'CACHE_REDIS_URL',
391
+ value: 'redis://localhost:6379',
392
+ comment: 'Redis URL for cache',
393
+ required: false,
394
+ },
395
+ {
396
+ key: 'CACHE_TTL',
397
+ value: '3600',
398
+ comment: 'Default cache TTL in seconds',
399
+ required: true,
400
+ },
401
+ ],
402
+ },
403
+ ],
404
+ mfa: [
405
+ {
406
+ title: 'MFA/TOTP Configuration',
407
+ variables: [
408
+ {
409
+ key: 'MFA_ISSUER',
410
+ value: 'MyApp',
411
+ comment: 'MFA issuer name shown in authenticator apps',
412
+ required: true,
413
+ },
414
+ {
415
+ key: 'MFA_ALGORITHM',
416
+ value: 'SHA1',
417
+ comment: 'TOTP algorithm: SHA1, SHA256, or SHA512',
418
+ required: true,
419
+ },
420
+ ],
421
+ },
422
+ ],
423
+ oauth: [
424
+ {
425
+ title: 'OAuth Configuration',
426
+ variables: [
427
+ {
428
+ key: 'OAUTH_GOOGLE_CLIENT_ID',
429
+ value: '',
430
+ comment: 'Google OAuth client ID',
431
+ required: false,
432
+ },
433
+ {
434
+ key: 'OAUTH_GOOGLE_CLIENT_SECRET',
435
+ value: '',
436
+ comment: 'Google OAuth client secret',
437
+ required: false,
438
+ },
439
+ {
440
+ key: 'OAUTH_GITHUB_CLIENT_ID',
441
+ value: '',
442
+ comment: 'GitHub OAuth client ID',
443
+ required: false,
444
+ },
445
+ {
446
+ key: 'OAUTH_GITHUB_CLIENT_SECRET',
447
+ value: '',
448
+ comment: 'GitHub OAuth client secret',
449
+ required: false,
450
+ },
451
+ {
452
+ key: 'OAUTH_REDIRECT_URL',
453
+ value: 'http://localhost:3000/auth/callback',
454
+ comment: 'OAuth callback URL',
455
+ required: true,
456
+ },
457
+ ],
458
+ },
459
+ ],
460
+ payment: [
461
+ {
462
+ title: 'Payment Configuration',
463
+ variables: [
464
+ {
465
+ key: 'STRIPE_SECRET_KEY',
466
+ value: '',
467
+ comment: 'Stripe secret key',
468
+ required: false,
469
+ },
470
+ {
471
+ key: 'STRIPE_PUBLISHABLE_KEY',
472
+ value: '',
473
+ comment: 'Stripe publishable key',
474
+ required: false,
475
+ },
476
+ {
477
+ key: 'PAYPAL_CLIENT_ID',
478
+ value: '',
479
+ comment: 'PayPal client ID',
480
+ required: false,
481
+ },
482
+ {
483
+ key: 'PAYPAL_CLIENT_SECRET',
484
+ value: '',
485
+ comment: 'PayPal client secret',
486
+ required: false,
487
+ },
488
+ {
489
+ key: 'PAYPAL_MODE',
490
+ value: 'sandbox',
491
+ comment: 'PayPal mode: sandbox or live',
492
+ required: false,
493
+ },
494
+ ],
495
+ },
496
+ ],
497
+ 'feature-flag': [
498
+ {
499
+ title: 'Feature Flags Configuration',
500
+ variables: [
501
+ {
502
+ key: 'FEATURE_FLAGS_ENABLED',
503
+ value: 'true',
504
+ comment: 'Enable feature flags',
505
+ required: true,
506
+ },
507
+ {
508
+ key: 'FEATURE_FLAGS_ENVIRONMENT',
509
+ value: 'development',
510
+ comment: 'Feature flags environment: development, staging, production, test',
511
+ required: true,
512
+ },
513
+ {
514
+ key: 'FEATURE_FLAGS_ANALYTICS',
515
+ value: 'true',
516
+ comment: 'Enable feature flag analytics',
517
+ required: true,
518
+ },
519
+ {
520
+ key: 'FEATURE_FLAGS_CACHE_TTL',
521
+ value: '300',
522
+ comment: 'Cache TTL in seconds',
523
+ required: true,
524
+ },
525
+ ],
526
+ },
527
+ ],
528
+ upload: [
529
+ {
530
+ title: 'File Upload Configuration',
531
+ variables: [
532
+ {
533
+ key: 'UPLOAD_PROVIDER',
534
+ value: 'local',
535
+ comment: 'Upload provider: local, s3, cloudinary',
536
+ required: true,
537
+ },
538
+ {
539
+ key: 'UPLOAD_MAX_SIZE',
540
+ value: '10485760',
541
+ comment: 'Max upload size in bytes (10MB)',
542
+ required: true,
543
+ },
544
+ {
545
+ key: 'UPLOAD_DIR',
546
+ value: './uploads',
547
+ comment: 'Local upload directory',
548
+ required: true,
549
+ },
550
+ {
551
+ key: 'AWS_ACCESS_KEY_ID',
552
+ value: '',
553
+ comment: 'AWS access key for S3',
554
+ required: false,
555
+ },
556
+ {
557
+ key: 'AWS_SECRET_ACCESS_KEY',
558
+ value: '',
559
+ comment: 'AWS secret key for S3',
560
+ required: false,
561
+ },
562
+ {
563
+ key: 'AWS_S3_BUCKET',
564
+ value: '',
565
+ comment: 'S3 bucket name',
566
+ required: false,
567
+ },
568
+ ],
569
+ },
570
+ ],
571
+ notification: [
572
+ {
573
+ title: 'Notification Configuration',
574
+ variables: [
575
+ {
576
+ key: 'NOTIFICATION_EMAIL_ENABLED',
577
+ value: 'true',
578
+ comment: 'Enable email notifications',
579
+ required: true,
580
+ },
581
+ {
582
+ key: 'NOTIFICATION_SMS_ENABLED',
583
+ value: 'false',
584
+ comment: 'Enable SMS notifications',
585
+ required: false,
586
+ },
587
+ {
588
+ key: 'NOTIFICATION_PUSH_ENABLED',
589
+ value: 'false',
590
+ comment: 'Enable push notifications',
591
+ required: false,
592
+ },
593
+ {
594
+ key: 'TWILIO_ACCOUNT_SID',
595
+ value: '',
596
+ comment: 'Twilio account SID for SMS',
597
+ required: false,
598
+ },
599
+ {
600
+ key: 'TWILIO_AUTH_TOKEN',
601
+ value: '',
602
+ comment: 'Twilio auth token',
603
+ required: false,
604
+ },
605
+ ],
606
+ },
607
+ ],
608
+ analytics: [
609
+ {
610
+ title: 'Analytics/Metrics Configuration',
611
+ variables: [
612
+ {
613
+ key: 'ANALYTICS_ENABLED',
614
+ value: 'true',
615
+ comment: 'Enable analytics and metrics collection',
616
+ required: true,
617
+ },
618
+ {
619
+ key: 'ANALYTICS_PREFIX',
620
+ value: 'app',
621
+ comment: 'Metrics prefix',
622
+ required: true,
623
+ },
624
+ {
625
+ key: 'PROMETHEUS_ENABLED',
626
+ value: 'true',
627
+ comment: 'Enable Prometheus metrics endpoint',
628
+ required: true,
629
+ },
630
+ {
631
+ key: 'METRICS_FLUSH_INTERVAL',
632
+ value: '60000',
633
+ comment: 'Metrics flush interval in milliseconds',
634
+ required: true,
635
+ },
636
+ ],
637
+ },
638
+ ],
639
+ 'media-processing': [
640
+ {
641
+ title: 'Media Processing Configuration',
642
+ variables: [
643
+ {
644
+ key: 'FFMPEG_PATH',
645
+ value: 'ffmpeg',
646
+ comment: 'Path to FFmpeg binary',
647
+ required: true,
648
+ },
649
+ {
650
+ key: 'FFPROBE_PATH',
651
+ value: 'ffprobe',
652
+ comment: 'Path to FFprobe binary',
653
+ required: true,
654
+ },
655
+ {
656
+ key: 'MEDIA_TEMP_DIR',
657
+ value: './temp/media',
658
+ comment: 'Temporary directory for media processing',
659
+ required: true,
660
+ },
661
+ {
662
+ key: 'MEDIA_MAX_CONCURRENT',
663
+ value: '3',
664
+ comment: 'Maximum concurrent processing jobs',
665
+ required: true,
666
+ },
667
+ {
668
+ key: 'MEDIA_GPU_ACCELERATION',
669
+ value: 'false',
670
+ comment: 'Enable GPU acceleration (requires NVIDIA GPU)',
671
+ required: false,
672
+ },
673
+ ],
674
+ },
675
+ ],
676
+ 'api-versioning': [
677
+ {
678
+ title: 'API Versioning Configuration',
679
+ variables: [
680
+ {
681
+ key: 'API_VERSION_STRATEGY',
682
+ value: 'url',
683
+ comment: 'Versioning strategy: url, header, query, accept-header',
684
+ required: true,
685
+ },
686
+ {
687
+ key: 'API_DEFAULT_VERSION',
688
+ value: 'v1',
689
+ comment: 'Default API version',
690
+ required: true,
691
+ },
692
+ {
693
+ key: 'API_VERSION_HEADER',
694
+ value: 'X-API-Version',
695
+ comment: 'Header name for version (if strategy is header)',
696
+ required: false,
697
+ },
698
+ {
699
+ key: 'API_VERSION_STRICT',
700
+ value: 'true',
701
+ comment: 'Strict mode - reject unknown versions',
702
+ required: true,
703
+ },
704
+ {
705
+ key: 'API_DEPRECATION_WARNINGS',
706
+ value: 'true',
707
+ comment: 'Show deprecation warnings in headers',
708
+ required: true,
709
+ },
710
+ ],
711
+ },
712
+ ],
713
+ };
714
+
715
+ return moduleEnvMap[moduleName] || [];
716
+ }
717
+ }