express-project-builder 1.0.16 → 1.0.18

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 (2) hide show
  1. package/README.md +74 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -453,3 +453,77 @@ export const ProductValidation = {
453
453
  createProduct_ValidationZodSchema,
454
454
  };
455
455
  ```
456
+
457
+ - /src/**routers/index.ts** <br/>
458
+ Centralized router file for grouping and exporting all route modules.
459
+
460
+ ```typescript
461
+ // In your src/routers/index.ts
462
+ import { ProductRoutes } from "../modules/product/product_route";
463
+
464
+ // Define all route modules with their paths
465
+ const moduleRoutes = [
466
+ {
467
+ path: "/products",
468
+ route: ProductRoutes,
469
+ },
470
+ {
471
+ path: "/new-route",
472
+ route: NewRouteRoutes,
473
+ },
474
+ ];
475
+
476
+ // Creating a New Route Group
477
+ // Create new route file: src/routers/new-route.ts
478
+ import { Router } from "express";
479
+ const newRouters = Router();
480
+
481
+ // Define routes for this group
482
+ const moduleRoutes = [
483
+ {
484
+ path: "/new-version",
485
+ route: newVersionRoutes,
486
+ },
487
+ ];
488
+
489
+ // Register routes in this group
490
+ moduleRoutes.forEach((route) => {
491
+ newRouters.use(route.path, route.route);
492
+ });
493
+
494
+ export default newRouters;
495
+
496
+ // Applying in app.ts:
497
+ import routers from "./routers";
498
+ import newRouters from "./routers/new-route";
499
+
500
+ // Apply main routes with version prefix
501
+ app.use("/v1/api", routers);
502
+
503
+ // Apply new route group with different version
504
+ app.use("/v2/api", newRouters);
505
+ ```
506
+
507
+ - /src/utils/**catchAsync.ts**
508
+ Utility function that wraps asynchronous route handlers to automatically catch errors and pass them to the next error-handling middleware.
509
+
510
+ ```typescript
511
+ // In your Controller file , Like : product_controllet.ts
512
+ import catchAsync from "../../utils/catchAsync";
513
+
514
+ const get_All_Products = catchAsync(async (req, res) => {
515
+ // Your async controller logic here
516
+ const result = await Product_Services.get_All_Products_FromDB(
517
+ req.body,
518
+ req.query
519
+ );
520
+
521
+ res.status(200).json({
522
+ data: result,
523
+ });
524
+ });
525
+
526
+ export const Product_Controllers = {
527
+ get_All_Products,
528
+ };
529
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-project-builder",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "A powerful and professional Express.js project generator CLI that instantly scaffolds a production-ready backend with TypeScript, modular architecture, and built-in support for MongoDB (Mongoose) or PostgreSQL (Prisma). Includes authentication, error handling, rate limiting, file upload, caching, and utility functions—so you can focus on building features instead of boilerplate. Perfect for kickstarting your next Express.js API project with best practices and modern tools.",
5
5
  "type": "module",
6
6
  "main": "dist/bin/index.js",