express-project-builder 1.0.23 → 1.0.24

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 +43 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -724,3 +724,46 @@ await sendEmail(payload.email, emailTemplate);
724
724
  // Test email configuration
725
725
  await testEmailConfig();
726
726
  ```
727
+
728
+ - /src/utils/**sendResponse.ts** <br/>
729
+ Utility function for sending standardized API responses with appropriate status codes, success flags, and data.
730
+
731
+ ```typescript
732
+ // In your Controller file (e.g., product_controller.ts)
733
+ import sendResponse from "../../utils/sendResponse";
734
+
735
+ // Traditional approach without sendResponse utility
736
+ const get_AllProducts = catchAsync(async (req, res) => {
737
+ const result = await Product_Services.fetch_AllProductsFromDB(
738
+ req.params.user_id,
739
+ req.query
740
+ );
741
+
742
+ res.status(200).json({
743
+ success: true,
744
+ message: "Products are retrieved successfully!",
745
+ data: result.result,
746
+ meta: result.meta,
747
+ });
748
+ });
749
+
750
+ // Using sendResponse utility
751
+ const get_AllProducts = catchAsync(async (req, res) => {
752
+ const result = await Product_Services.fetch_AllProductsFromDB(
753
+ req.params.user_id,
754
+ req.query
755
+ );
756
+
757
+ sendResponse(res, {
758
+ status: 200,
759
+ success: true,
760
+ message: "Products are retrieved successfully!",
761
+ data: result.result,
762
+ meta: result.meta, // meta is optional object.
763
+ });
764
+ });
765
+
766
+ export const Product_Controllers = {
767
+ get_AllProducts,
768
+ };
769
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-project-builder",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
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",