@asad_dev/leo-generator 1.6.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 (38) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/COMMAND_REFERENCE.md +412 -0
  3. package/README.md +486 -0
  4. package/dist/app/modules/imagemodule/imagemodule.constants.js +18 -0
  5. package/dist/app/modules/imagemodule/imagemodule.controller.js +98 -0
  6. package/dist/app/modules/imagemodule/imagemodule.interface.js +2 -0
  7. package/dist/app/modules/imagemodule/imagemodule.model.js +10 -0
  8. package/dist/app/modules/imagemodule/imagemodule.route.js +20 -0
  9. package/dist/app/modules/imagemodule/imagemodule.service.js +137 -0
  10. package/dist/app/modules/imagemodule/imagemodule.validation.js +12 -0
  11. package/dist/app/modules/skiptest/skiptest.controller.js +81 -0
  12. package/dist/app/modules/skiptest/skiptest.route.js +19 -0
  13. package/dist/app/modules/skiptest/skiptest.service.js +129 -0
  14. package/dist/app/modules/skiptest/skiptest.validation.js +12 -0
  15. package/dist/app/modules/testmodule/testmodule.constants.js +18 -0
  16. package/dist/app/modules/testmodule/testmodule.controller.js +81 -0
  17. package/dist/app/modules/testmodule/testmodule.interface.js +2 -0
  18. package/dist/app/modules/testmodule/testmodule.model.js +11 -0
  19. package/dist/app/modules/testmodule/testmodule.route.js +19 -0
  20. package/dist/app/modules/testmodule/testmodule.service.js +129 -0
  21. package/dist/app/modules/testmodule/testmodule.validation.js +14 -0
  22. package/dist/helpers/fileHelper.js +44 -0
  23. package/dist/index.js +586 -0
  24. package/dist/templates/constants.template.js +24 -0
  25. package/dist/templates/controller.template.js +108 -0
  26. package/dist/templates/route.template.js +68 -0
  27. package/dist/templates/service.template.js +184 -0
  28. package/dist/types.js +2 -0
  29. package/dist/utils/documentationUpdater.js +430 -0
  30. package/dist/utils/fieldParser.js +163 -0
  31. package/dist/utils/helperGenerator.js +87 -0
  32. package/dist/utils/interfaceGenerator.js +158 -0
  33. package/dist/utils/modelGenerator.js +140 -0
  34. package/dist/utils/postmanApi.js +113 -0
  35. package/dist/utils/postmanGenerator.js +283 -0
  36. package/dist/utils/swaggerGenerator.js +444 -0
  37. package/dist/utils/validationGenerator.js +170 -0
  38. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,486 @@
1
+ # Leo Generate - Enhanced Module Generator (v1.6.0)
2
+
3
+ A powerful, production-ready module generator for Express.js applications with Mongoose models, automated Postman Cloud sync, and Swagger documentation.
4
+
5
+
6
+ ## 🚀 Features
7
+
8
+ ### Core Module Generation
9
+ - 📁 Complete folder structure with TypeScript support
10
+ - 🧩 Advanced TypeScript interfaces with nested types
11
+ - 🔄 Mongoose models with complex schema support
12
+ - 🎮 Production-ready Express controllers with pagination
13
+ - 🛠️ Enhanced service layer with error handling
14
+ - 🛣️ RESTful routes with validation middleware
15
+ - ✅ Zod validation with nested object support
16
+ - ✅ Zod validation with nested object support
17
+ - 🎨 Clean and consistent code structure
18
+ - 🚮 Optional file cleanup on delete (with `--file:true`)
19
+
20
+ ### Advanced Field Support
21
+ - 🔣 Enum fields with predefined values
22
+ - 🏗️ Complex nested objects and arrays
23
+ - 📊 Array of objects with defined structures
24
+ - 🔗 ObjectId references with auto-population
25
+ - 📁 File upload handling
26
+ - 🔍 Search and pagination support
27
+
28
+ ### Smart Documentation Generation
29
+ - 📮 **Automatic Postman Collections** - Generate complete API collections
30
+ - ☁️ **Automated Postman Sync** - Automatically sync APIs to Postman Cloud collections
31
+ - 📖 **Swagger Documentation** - Auto-generate OpenAPI 3.0 specs
32
+ - 🔄 **Intelligent Documentation Updates** - Analyzes your code changes and updates docs accordingly
33
+ - 🧠 **Code-Aware Parsing** - Reads both interface and model files for accurate field extraction
34
+ - 📂 **Organized Output** - Separate folders for documentation types
35
+ - ⚡ **Dynamic Values** - Pre-request scripts auto-generate random values for testing
36
+ - ✅ **100% Syntax Support** - Handles ALL field types the generator can create
37
+
38
+ ## 📦 Installation
39
+
40
+ ```bash
41
+ npm install @asad_dev/leo-generator --global
42
+ ```
43
+
44
+ Or use with npx:
45
+
46
+ ```bash
47
+ npx leo-generate
48
+ ```
49
+
50
+ ## 🎯 Quick Start
51
+
52
+ ### Basic Module Generation
53
+
54
+ ```bash
55
+ # Primary command (recommended)
56
+ leo-generate generate User name:string email:string age:number
57
+
58
+ # Short alias
59
+ leo-generate g User name:string email:string
60
+
61
+ # Legacy support (still works)
62
+ leo-generate User name:string email:string age:number
63
+ ```
64
+
65
+ ## 📋 **Quick Command Reference**
66
+
67
+ | Command | Purpose | Example |
68
+ |---------|---------|---------|
69
+ | `generate <name> [fields...]` | Create new module | `leo-generate generate User name:string email:string` |
70
+ | `g <name> [fields...]` | Short alias for generate | `leo-generate g Product name:string price:number` |
71
+ | `update-docs` | Update all documentation | `leo-generate update-docs` |
72
+ | `docs` | Short alias for update-docs | `leo-generate docs` |
73
+ | `<name> [fields...]` | Legacy syntax | `leo-generate User name:string email:string` |
74
+
75
+ ### **Common Options**
76
+ - `--no-postman` - Skip Postman collection generation
77
+ - `--no-swagger` - Skip Swagger documentation generation
78
+ - `--postman-dir <path>` - Custom Postman output directory
79
+ - `--swagger-file <path>` - Custom Swagger file path
80
+ - `--modules-dir <path>` - Custom modules directory
81
+
82
+ This creates:
83
+
84
+ ```
85
+ src/app/modules/user/
86
+ ├── user.interface.ts // Enhanced TypeScript interfaces
87
+ ├── user.model.ts // Mongoose model with validation
88
+ ├── user.controller.ts // Production-ready controllers
89
+ ├── user.service.ts // Enhanced service layer
90
+ ├── user.route.ts // RESTful routes
91
+ ├── user.validation.ts // Zod validation schemas
92
+ └── user.constants.ts // Constants
93
+
94
+ postman/
95
+ └── user.postman_collection.json // Auto-generated Postman collection
96
+
97
+ swagger.json // Updated with new endpoints
98
+ ```
99
+
100
+ ## 🛠️ Commands
101
+
102
+ ### Generate Module
103
+ ```bash
104
+ leo-generate generate <ModuleName> [fields...] [options]
105
+
106
+ # Options:
107
+ --no-postman # Skip Postman collection generation
108
+ --no-swagger # Skip Swagger documentation
109
+ --postman-dir <path> # Custom Postman output directory
110
+ --swagger-file <path> # Custom Swagger file path
111
+ --modules-dir <path> # Custom modules directory
112
+ --routes-file <path> # Custom routes file
113
+ --file:true # Enable file upload support (generates async cleanup helpers)
114
+ --skip <files...> # Skip specific file types (e.g., interface model constants)
115
+ ```
116
+
117
+ ### Smart Documentation Updates
118
+ ```bash
119
+ # Intelligently updates documentation for all existing modules
120
+ leo-generate update-docs
121
+
122
+ # Aliases:
123
+ leo-generate docs
124
+
125
+ # The system automatically:
126
+ # ✅ Scans all modules in your project
127
+ # ✅ Reads both interface and model files
128
+ # ✅ Extracts current field definitions
129
+ # ✅ Generates accurate Postman collections
130
+ # ✅ Updates Swagger documentation
131
+ # ✅ Handles complex nested structures
132
+ # ✅ Preserves enum values and references
133
+
134
+ # Options:
135
+ --modules-dir <path> # Path to modules directory
136
+ --no-postman # Skip Postman updates
137
+ --no-swagger # Skip Swagger updates
138
+ --postman-dir <path> # Custom Postman output directory
139
+ --swagger-file <path> # Custom Swagger file path
140
+ ```
141
+
142
+ ## 🏗️ Advanced Examples
143
+
144
+ ### Complex Nested Structures
145
+
146
+ ```bash
147
+ # E-commerce Order with nested items
148
+ leo-generate generate Order \
149
+ customer:objectid:User \
150
+ items:array:object:name:string:price:number:quantity:number \
151
+ status:enum[pending,processing,shipped,delivered] \
152
+ shippingAddress:object:street:string:city:string:zipCode:string \
153
+ totalAmount:number \
154
+ createdAt:date
155
+ ```
156
+
157
+ ### Blog System with References
158
+
159
+ ```bash
160
+ # Blog post with author reference and tags
161
+ leo-generate generate Post \
162
+ title!:string \
163
+ content!:string \
164
+ author:objectid:User \
165
+ tags:array:string \
166
+ status:enum[draft,published,archived] \
167
+ publishedAt?:date \
168
+ viewCount:number
169
+ ```
170
+
171
+ ### Product Catalog with Variants
172
+
173
+ ```bash
174
+ # Product with multiple variants
175
+ leo-generate generate Product \
176
+ name!:string \
177
+ description:string \
178
+ category:enum[Electronics,Clothing,Books,Home] \
179
+ variants:array:object:size:string:color:string:price:number:stock:number \
180
+ images:array:string \
181
+ isActive:boolean
182
+ ```
183
+
184
+ ## 📋 Field Types & Syntax
185
+
186
+ ### Basic Types
187
+ ```bash
188
+ name:string # String field
189
+ age:number # Number field
190
+ isActive:boolean # Boolean field
191
+ createdAt:date # Date field
192
+ ```
193
+
194
+ ### Modifiers
195
+ ```bash
196
+ name!:string # Required field
197
+ email?:string # Optional field
198
+ ```
199
+
200
+ ### Enums
201
+ ```bash
202
+ status:enum[active,inactive,pending]
203
+ role:enum[admin,user,moderator]
204
+ ```
205
+
206
+ ### References
207
+ ```bash
208
+ author:objectid:User # Single reference
209
+ categories:array:objectid:Category # Array of references
210
+ ```
211
+
212
+ ### Complex Structures
213
+ ```bash
214
+ # Array of objects
215
+ items:array:object:name:string:price:number:quantity:number
216
+
217
+ # Nested object
218
+ address:object:street:string:city:string:country:string
219
+
220
+ # Mixed arrays
221
+ tags:array:string
222
+ scores:array:number
223
+ ```
224
+
225
+ ## 🎮 Generated API Features
226
+
227
+ ### Enhanced Controllers
228
+ - ✅ Pagination support with meta information
229
+ - 🔍 Search functionality across string fields
230
+ - 📊 Sorting with customizable fields
231
+ - 🛡️ Input validation and sanitization
232
+ - 📁 File upload handling
233
+ - ⚡ Error handling with proper HTTP status codes
234
+
235
+ ### Production-Ready Services
236
+ - 🔒 ObjectId validation
237
+ - 🔄 Auto-population of references
238
+ - 🗑️ Proper file cleanup on deletion
239
+ - 📈 Optimized queries with lean()
240
+ - 🔍 Advanced search with regex
241
+ - 📊 Aggregation support
242
+
243
+ ### API Endpoints
244
+ For a module named "Product":
245
+
246
+ ```
247
+ POST /api/v1/products # Create product
248
+ GET /api/v1/products # Get all (with pagination, search, sort)
249
+ GET /api/v1/products/:id # Get single product
250
+ PATCH /api/v1/products/:id # Update product
251
+ DELETE /api/v1/products/:id # Delete product
252
+
253
+ Query Parameters for GET /api/v1/products:
254
+ ?page=1&limit=10&search=keyword&sortBy=createdAt&sortOrder=desc
255
+ ```
256
+
257
+ ## 📮 Postman Integration
258
+
259
+ ### Auto-Generated Collections
260
+ - 🔄 Complete CRUD operations
261
+ - 📝 Sample request bodies with realistic data
262
+ - 🔗 Environment variables for base URL
263
+ - 📊 Proper HTTP methods and headers
264
+ - 🎯 Parameter examples for all endpoints
265
+
266
+ ### Collection Structure
267
+ ```json
268
+ {
269
+ "info": {
270
+ "name": "Product API",
271
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
272
+ },
273
+ "item": [
274
+ {
275
+ "name": "Create Product",
276
+ "request": {
277
+ "method": "POST",
278
+ "body": {
279
+ "mode": "raw",
280
+ "raw": "{\n \"name\": \"sample_name\",\n \"price\": 123\n}"
281
+ }
282
+ }
283
+ }
284
+ ]
285
+ }
286
+ ```
287
+
288
+ ## ☁️ Automated Postman Cloud Sync
289
+
290
+ Leo Generate can automatically sync your generated collections to the Postman Cloud.
291
+
292
+ ### Configuration
293
+ Update your `.env` file or `package.json` with your Postman credentials:
294
+
295
+ ```env
296
+ POSTMAN_API_KEY=your_api_key
297
+ POSTMAN_COLLECTION_ID=your_collection_uid
298
+ ```
299
+
300
+ ### How it Works
301
+ 1. When you run `generate` or `update-docs`, the system checks for credentials.
302
+ 2. It fetches your existing collection from Postman Cloud.
303
+ 3. It intelligently merges the new/updated module folder into the collection.
304
+ 4. It updates the cloud collection via the Postman API.
305
+
306
+ ## 🗑️ Intelligent File Cleanup
307
+
308
+ When generating a module with `--file:true`, the system adds asynchronous cleanup logic:
309
+
310
+ - **Service Layer**: Automatically `await`s file removal on record deletion or creation failure.
311
+ - **Helper Utility**: Generates a robust `removeFile` helper using `fs/promises`.
312
+ - **Path Logic**: Automatically handles `/images/` prefix and path normalization.
313
+
314
+ ### Auto-Generated Documentation
315
+ - 📋 OpenAPI 3.0 specification
316
+ - 🏷️ Proper tags and descriptions
317
+ - 📝 Request/response schemas
318
+ - 🔍 Parameter documentation
319
+ - ✅ Validation rules included
320
+ - 🔄 Automatic updates on module changes
321
+
322
+ ### Schema Generation
323
+ ```yaml
324
+ components:
325
+ schemas:
326
+ Product:
327
+ type: object
328
+ properties:
329
+ _id:
330
+ type: string
331
+ description: MongoDB ObjectId
332
+ name:
333
+ type: string
334
+ description: name field
335
+ price:
336
+ type: number
337
+ description: price field
338
+ createdAt:
339
+ type: string
340
+ format: date-time
341
+ required:
342
+ - _id
343
+ - name
344
+ ```
345
+
346
+ ## ⚙️ Configuration
347
+
348
+ ### Via package.json
349
+ ```json
350
+ {
351
+ "moduleGenerator": {
352
+ "modulesDir": "src/app/modules",
353
+ "routesFile": "src/routes/index.ts"
354
+ }
355
+ }
356
+ ```
357
+
358
+ ### Via CLI Options
359
+ ```bash
360
+ leo-generate generate User name:string \
361
+ --modules-dir src/modules \
362
+ --routes-file src/routes.ts \
363
+ --postman-dir collections \
364
+ --swagger-file api-docs.json
365
+ ```
366
+
367
+ ## 🧠 Enhanced Documentation Intelligence (v1.2.0)
368
+
369
+ ### **Code-Aware Documentation Updates**
370
+ The enhanced system now intelligently analyzes your code changes:
371
+
372
+ ```bash
373
+ # Example: You modify an Order model
374
+ # BEFORE: items had name, price, quantity
375
+ # AFTER: items only have name (removed price, quantity)
376
+
377
+ # Simply run:
378
+ leo-generate update-docs
379
+
380
+ # The system will:
381
+ # ✅ Read your modified interface and model files
382
+ # ✅ Detect that items now only have 'name' field
383
+ # ✅ Update Postman collections: {"items": [{"name": "sample_name"}]}
384
+ # ✅ Update Swagger schemas to reflect current structure
385
+ # ✅ Handle ALL field types: enums, arrays, nested objects, references
386
+ ```
387
+
388
+ ### **100% Syntax Support**
389
+ Every field type the generator can create is fully supported in updates:
390
+
391
+ | Syntax | Generated Sample | Update Support |
392
+ |--------|------------------|----------------|
393
+ | `name:string` | `"name": "sample_name"` | ✅ Perfect |
394
+ | `age:number` | `"age": 123` | ✅ Perfect |
395
+ | `tags:array:string` | `"tags": ["sample_item"]` | ✅ Perfect |
396
+ | `scores:array:number` | `"scores": [123]` | ✅ Perfect |
397
+ | `status:enum[active,inactive]` | `"status": "active"` | ✅ Perfect |
398
+ | `author:objectid:User` | `"author": "507f1f77..."` | ✅ Perfect |
399
+ | `items:array:object:name:string:price:number` | `"items": [{"name": "...", "price": 123}]` | ✅ Perfect |
400
+
401
+ ## 🔄 Migration from v1.1
402
+
403
+ The new version maintains backward compatibility:
404
+
405
+ ```bash
406
+ # Old way (still works)
407
+ leo-generate User name:string email:string
408
+
409
+ # New way (recommended)
410
+ leo-generate generate User name:string email:string
411
+
412
+ # Enhanced documentation updates
413
+ leo-generate update-docs
414
+ ```
415
+
416
+ ## 🎯 Best Practices
417
+
418
+ ### Module Design
419
+ 1. Use singular names for modules (e.g., "User" not "Users")
420
+ 2. Mark required fields with "!" suffix
421
+ 3. Use descriptive field names
422
+ 4. Group related fields logically
423
+ 5. Consider using enums for status fields
424
+
425
+ ### Field Naming
426
+ ```bash
427
+ # Good
428
+ leo-generate generate User name!:string email!:string status:enum[active,inactive]
429
+
430
+ # Avoid
431
+ leo-generate generate Users NAME:string Email:string stat:string
432
+ ```
433
+
434
+ ### Complex Structures
435
+ ```bash
436
+ # Prefer structured objects over loose data
437
+ leo-generate generate Order \
438
+ items:array:object:productId:objectid:Product:quantity:number:price:number \
439
+ # Instead of: items:array:string
440
+ ```
441
+
442
+ ## 🚀 Performance Features
443
+
444
+ ### Optimized Queries
445
+ - 📊 Lean queries for list operations
446
+ - 🔍 Indexed search fields
447
+ - 📈 Aggregation pipeline support
448
+ - 🔄 Efficient population of references
449
+
450
+ ### Caching Ready
451
+ - 🏪 Service layer designed for caching integration
452
+ - 🔑 Consistent data access patterns
453
+ - ⚡ Optimized for Redis integration
454
+
455
+ ## 🛡️ Security Features
456
+
457
+ ### Input Validation
458
+ - ✅ Zod schema validation
459
+ - 🛡️ XSS protection ready
460
+ - 📝 Sanitized inputs
461
+ - 🔒 Type-safe operations
462
+
463
+ ### File Upload Security
464
+ - 📁 Proper file type validation
465
+ - 🗑️ Automatic cleanup on errors
466
+ - 📊 Size limit enforcement ready
467
+
468
+ ## 🤝 Contributing
469
+
470
+ Contributions are welcome! Please feel free to submit a Pull Request.
471
+
472
+ ### Development Setup
473
+ ```bash
474
+ git clone <repository>
475
+ cd leo-generator
476
+ npm install
477
+ npm run build
478
+ ```
479
+
480
+ ## 📄 License
481
+
482
+ MIT
483
+
484
+ ---
485
+
486
+ **Leo Generate** - Because generating quality code should be as smooth as Leo's dribbling! ⚽
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSetEqual = exports.imagemoduleSearchableFields = exports.imagemoduleFilterables = void 0;
4
+ // Filterable fields for Imagemodule
5
+ exports.imagemoduleFilterables = [];
6
+ // Searchable fields for Imagemodule
7
+ exports.imagemoduleSearchableFields = [];
8
+ // Helper function for set comparison
9
+ const isSetEqual = (setA, setB) => {
10
+ if (setA.size !== setB.size)
11
+ return false;
12
+ for (const item of setA) {
13
+ if (!setB.has(item))
14
+ return false;
15
+ }
16
+ return true;
17
+ };
18
+ exports.isSetEqual = isSetEqual;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ImagemoduleController = void 0;
27
+ const imagemodule_service_1 = require("./imagemodule.service");
28
+ const catchAsync_1 = __importDefault(require("../../../shared/catchAsync"));
29
+ const sendResponse_1 = __importDefault(require("../../../shared/sendResponse"));
30
+ const http_status_codes_1 = require("http-status-codes");
31
+ const pick_1 = __importDefault(require("../../../shared/pick"));
32
+ const imagemodule_constants_1 = require("./imagemodule.constants");
33
+ const pagination_1 = require("../../../interfaces/pagination");
34
+ const createImagemodule = (0, catchAsync_1.default)((req, res) => __awaiter(void 0, void 0, void 0, function* () {
35
+ const _a = req.body, { images, media } = _a, imagemoduleData = __rest(_a, ["images", "media"]);
36
+ if (images && images.length > 0) {
37
+ imagemoduleData.images = images;
38
+ }
39
+ if (media && media.length > 0) {
40
+ imagemoduleData.media = media;
41
+ }
42
+ const result = yield imagemodule_service_1.ImagemoduleServices.createImagemodule(req.user, imagemoduleData);
43
+ (0, sendResponse_1.default)(res, {
44
+ statusCode: http_status_codes_1.StatusCodes.CREATED,
45
+ success: true,
46
+ message: 'Imagemodule created successfully',
47
+ data: result,
48
+ });
49
+ }));
50
+ const updateImagemodule = (0, catchAsync_1.default)((req, res) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const { id } = req.params;
52
+ const imagemoduleData = req.body;
53
+ const result = yield imagemodule_service_1.ImagemoduleServices.updateImagemodule(id, imagemoduleData);
54
+ (0, sendResponse_1.default)(res, {
55
+ statusCode: http_status_codes_1.StatusCodes.OK,
56
+ success: true,
57
+ message: 'Imagemodule updated successfully',
58
+ data: result,
59
+ });
60
+ }));
61
+ const getSingleImagemodule = (0, catchAsync_1.default)((req, res) => __awaiter(void 0, void 0, void 0, function* () {
62
+ const { id } = req.params;
63
+ const result = yield imagemodule_service_1.ImagemoduleServices.getSingleImagemodule(id);
64
+ (0, sendResponse_1.default)(res, {
65
+ statusCode: http_status_codes_1.StatusCodes.OK,
66
+ success: true,
67
+ message: 'Imagemodule retrieved successfully',
68
+ data: result,
69
+ });
70
+ }));
71
+ const getAllImagemodules = (0, catchAsync_1.default)((req, res) => __awaiter(void 0, void 0, void 0, function* () {
72
+ const filterables = (0, pick_1.default)(req.query, imagemodule_constants_1.imagemoduleFilterables);
73
+ const pagination = (0, pick_1.default)(req.query, pagination_1.paginationFields);
74
+ const result = yield imagemodule_service_1.ImagemoduleServices.getAllImagemodules(req.user, filterables, pagination);
75
+ (0, sendResponse_1.default)(res, {
76
+ statusCode: http_status_codes_1.StatusCodes.OK,
77
+ success: true,
78
+ message: 'Imagemodules retrieved successfully',
79
+ data: result,
80
+ });
81
+ }));
82
+ const deleteImagemodule = (0, catchAsync_1.default)((req, res) => __awaiter(void 0, void 0, void 0, function* () {
83
+ const { id } = req.params;
84
+ const result = yield imagemodule_service_1.ImagemoduleServices.deleteImagemodule(id);
85
+ (0, sendResponse_1.default)(res, {
86
+ statusCode: http_status_codes_1.StatusCodes.OK,
87
+ success: true,
88
+ message: 'Imagemodule deleted successfully',
89
+ data: result,
90
+ });
91
+ }));
92
+ exports.ImagemoduleController = {
93
+ createImagemodule,
94
+ updateImagemodule,
95
+ getSingleImagemodule,
96
+ getAllImagemodules,
97
+ deleteImagemodule,
98
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Imagemodule = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const imagemoduleSchema = new mongoose_1.Schema({
6
+ image: { type: String },
7
+ }, {
8
+ timestamps: true
9
+ });
10
+ exports.Imagemodule = (0, mongoose_1.model)('Imagemodule', imagemoduleSchema);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ImagemoduleRoutes = void 0;
7
+ const express_1 = __importDefault(require("express"));
8
+ const imagemodule_controller_1 = require("./imagemodule.controller");
9
+ const imagemodule_validation_1 = require("./imagemodule.validation");
10
+ const validateRequest_1 = __importDefault(require("../../middleware/validateRequest"));
11
+ const auth_1 = __importDefault(require("../../middleware/auth"));
12
+ const user_1 = require("../../../enum/user");
13
+ const processReqBody_1 = require("../../middleware/processReqBody");
14
+ const router = express_1.default.Router();
15
+ router.get('/', (0, auth_1.default)(user_1.USER_ROLES.SUPER_ADMIN, user_1.USER_ROLES.ADMIN), imagemodule_controller_1.ImagemoduleController.getAllImagemodules);
16
+ router.get('/:id', (0, auth_1.default)(user_1.USER_ROLES.SUPER_ADMIN, user_1.USER_ROLES.ADMIN), imagemodule_controller_1.ImagemoduleController.getSingleImagemodule);
17
+ router.post('/', (0, auth_1.default)(user_1.USER_ROLES.SUPER_ADMIN, user_1.USER_ROLES.ADMIN), (0, processReqBody_1.fileAndBodyProcessorUsingDiskStorage)(), (0, validateRequest_1.default)(imagemodule_validation_1.ImagemoduleValidations.createImagemoduleZodSchema), imagemodule_controller_1.ImagemoduleController.createImagemodule);
18
+ router.patch('/:id', (0, auth_1.default)(user_1.USER_ROLES.SUPER_ADMIN, user_1.USER_ROLES.ADMIN), (0, processReqBody_1.fileAndBodyProcessorUsingDiskStorage)(), (0, validateRequest_1.default)(imagemodule_validation_1.ImagemoduleValidations.updateImagemoduleZodSchema), imagemodule_controller_1.ImagemoduleController.updateImagemodule);
19
+ router.delete('/:id', (0, auth_1.default)(user_1.USER_ROLES.SUPER_ADMIN, user_1.USER_ROLES.ADMIN), imagemodule_controller_1.ImagemoduleController.deleteImagemodule);
20
+ exports.ImagemoduleRoutes = router;