express-project-builder 1.0.22 → 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 +66 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -701,3 +701,69 @@ await removeFilesFromFields(req.files, ["images", "documents"]);
701
701
  // Clean entire upload directory
702
702
  await cleanUploadDirectory("/path/to/uploads");
703
703
  ```
704
+
705
+ - /src/utils/**sendEmail.ts** <br/>
706
+ Utility functions for sending emails using Nodemailer with HTML content, attachments, and error handling.
707
+
708
+ ```typescript
709
+ // In your service file or any file
710
+ import sendEmail, { testEmailConfig } from "../../utils/sendEmail";
711
+ import { TEmailFormat } from "../../interfaces/emailFormat";
712
+
713
+ // Send email with HTML content
714
+ const emailTemplate: TEmailFormat = {
715
+ subject: "Welcome to Our Platform",
716
+ emailBody: `
717
+ <h1>Welcome!</h1>
718
+ <p>Thank you for joining our platform.</p>
719
+ `,
720
+ };
721
+
722
+ await sendEmail(payload.email, emailTemplate);
723
+
724
+ // Test email configuration
725
+ await testEmailConfig();
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.22",
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",