<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sweta Chauhan on Medium]]></title>
        <description><![CDATA[Stories by Sweta Chauhan on Medium]]></description>
        <link>https://medium.com/@swetachauhan_46203?source=rss-bef46f2db74a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zIO92yrbgAkDgWMW</url>
            <title>Stories by Sweta Chauhan on Medium</title>
            <link>https://medium.com/@swetachauhan_46203?source=rss-bef46f2db74a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:39:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@swetachauhan_46203/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Streamlining Nest.js Deployment on AWS with Travis CI]]></title>
            <link>https://medium.com/@swetachauhan_46203/streamlining-nest-js-deployment-on-aws-with-travis-ci-7d3b5c128ec8?source=rss-bef46f2db74a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d3b5c128ec8</guid>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Sweta Chauhan]]></dc:creator>
            <pubDate>Thu, 02 Apr 2026 12:52:38 GMT</pubDate>
            <atom:updated>2026-04-02T13:33:58.206Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><blockquote><em>In the dynamic landscape of web development, deploying a robust backend to the cloud is crucial for ensuring scalability, reliability, and efficient management of resources. Amazon Web Services (AWS) offers a comprehensive suite of services, and when combined with Travis CI, the continuous integration and deployment process becomes a seamless experience. This article will guide you through the process of deploying your Nest.js backend to AWS using services Elastic Container Registry (ECR), Elastic Beanstalk with Travis CI managing and coordinating the entire deployment pipeline.</em></blockquote><p><strong>Deployment Flow Overview</strong></p><p>GitHub → Travis CI → Docker Build → AWS ECR → Elastic Beanstalk → Live App</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4FoqHNnZobzssgRaUM8kKg.jpeg" /></figure><h3>Prerequisites</h3><ul><li>Basic knowledge of AWS .</li><li>Make sure you know the fundamentals of Nest.js. For official documentation, <a href="https://docs.nestjs.com/">click this link</a>.</li><li>A basic understanding of a Dockerfile and Docker.</li><li>Have a GitHub account for working with repositories . <a href="https://github.com/">Create one here</a></li><li>Node.js and npm (Node Package Manager) installed on your machine. Download them from the official Node.js website (<a href="https://nodejs.org/">https://nodejs.org</a>)</li></ul><h3>Setting Up AWS</h3><ul><li>Log in to the AWS Management Console using your AWS account credentials at <a href="https://aws.amazon.com/">https://aws.amazon.com/</a></li><li>Go to the IAM service dashboard and choose “Users” from the left-hand menu.</li><li>To create a new IAM user, click on the “Add user” button. Provide necessary information for the new user, including a meaningful username.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iYRzX7doPMH86dqQECOWkg.png" /></figure><ul><li>Attach policies to the user based on the specific permissions needed. AdministratorAccess-AWSElasticBeanstalk, AmazonEC2ContainerRegistryFullAccess respectively for accessing Elastic Beanstalk and Elastic Container Registry.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*goELrfZxruuF7wlBTJQdDA.png" /></figure><ul><li>Review and create the user by clicking “Create user” button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dczBqxzoszG1_jaDDno9OA.png" /></figure><ul><li>After Successful user creation, View the user details and click on “Create access key” in the summary section.</li><li>Click on Third-party Service and tick I understand checkboxand then next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIbUQX32uqWKNRwFpI1G2Q.png" /></figure><ul><li>Safely store these credentials as they won’t be retrievable later.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W91dQI0g3eqmdt7GMccKDQ.png" /></figure><h3>Create an Elastic Container Registry in AWS</h3><ul><li>Access the AWS Management Console.</li><li>Navigate to Elastic Container Repository.</li><li>Click “Create repository.”</li><li>Provide a repository name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UB6PV51SY0JOxiLsjJS8Ag.png" /></figure><ul><li>Click “Create repository” to finish.</li><li>After creation, select the repository and go to “View push commands” to get the Docker login command for pushing images.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lQRsuC2pPjKMP5EYSV95w.png" /></figure><p>“We will integrate the obtained push command into our Travis CI configuration for seamless automation of image pushing to the Elastic Container Registry during our deployment process.”</p><h3>Create Environment in Elastic Beanstalk</h3><ul><li>Access the AWS Management Console.</li><li>Navigate to Elastic Beanstalk service.</li><li>Click “Create Environment.”</li><li>Select the environment tier as Web server environment.</li><li>Give an application name.</li><li>Choose a platform as Docker.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*Jv_AWvce7fFls8kq_hYPDQ.png" /></figure><ul><li>Configure service access or click “skip to review” for default settings.</li><li>Review and click “submit” to initiate the setup process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zg8AXqwCckPhjvGgqMi2Aw.png" /></figure><ul><li>Monitor the environment creation progress in the Elastic Beanstalk dashboard.</li></ul><p>“We will incorporate the Elastic Beanstalk environment creation process into our Travis CI configuration, ensuring a streamlined and automated deployment pipeline for our application.”</p><blockquote>Note: Application name and Environment name will be used in Travis Ci configuration.</blockquote><h3>Setting up Nest.js Application</h3><h4>1. Create Nest.js Project</h4><p>You can create a new Nest project with the following commands in your OS terminal using Nest CLI.</p><pre>$ npm i -g @nestjs/cli<br>$ nest new aws-test-backend</pre><p>This command will generate a new NestJS project structure in the “project-name” directory. Once the command completes, navigate into the project directory:</p><pre>$ cd aws-test-backend</pre><p>Run the application by following the command</p><pre>yarn start:dev</pre><h4>2. Create a Dockerfile</h4><p>Now, create a file called Dockerfile in the project’s root folder.</p><pre>FROM --platform=linux/amd64 node:21-alpine AS base</pre><pre>FROM base AS deps</pre><pre>WORKDIR /app</pre><pre>COPY package.json yarn.lock* package-lock.json*  ./</pre><pre>RUN \<br>    if [ -f yarn.lock ]; then yarn --frozen-lockfile; \<br>    elif [ -f package-lock.json ]; then npm ci; \<br>    else echo &quot;Lockfile not found.&quot; &amp;&amp; exit 1; \<br>    fi</pre><pre>FROM base AS builder</pre><pre>WORKDIR /app</pre><pre>COPY --from=deps /app/node_modules ./node_modules<br>COPY . .</pre><pre>RUN yarn build</pre><pre>FROM base AS runner</pre><pre>WORKDIR /app</pre><pre>ENV NODE_ENV production</pre><pre>RUN addgroup --system --gid 1001 aws-test \<br>    &amp;&amp; adduser --system --uid 101 user</pre><pre>COPY --from=builder --chown=user:aws-test /app/node_modules/ ./node_modules/<br>COPY --from=builder --chown=user:aws-test /app/dist/ ./dist/</pre><pre>USER user</pre><pre>EXPOSE 3000</pre><pre># Command to run the application<br>CMD [&quot;node&quot;, &quot;dist/main.js&quot;]</pre><p>This Dockerfile is used to build a multi-stage Docker image for a Nest.js application. The multi-stage build allows you to separate the build dependencies from the final runtime image, resulting in a smaller and more secure image.</p><p>This Dockerfile is divided into three stages, each serving a specific purpose in the deployment process of a Nest.js application.</p><ol><li>Base Stage (base)</li></ol><ul><li>Uses node:21-alpine as the base image for Linux AMD64 architecture.</li><li>Sets up the working directory and copies package-related files.</li></ul><p>2. Dependencies Stage (deps):</p><ul><li>Inherits from the base stage.</li><li>Copies package files and installs dependencies using either Yarn or npm based on the lockfile present.</li></ul><p>3. Builder Stage (builder):</p><ul><li>Inherits from the base stage.</li><li>Copies dependencies from the deps stage.</li><li>Copies the entire application code.</li><li>Builds the application using the yarn build command.</li></ul><p>4. Runner Stage (runner):</p><ul><li>Inherits from the base stage.</li><li>Sets the working directory, environment variable, and creates a user for running the application.</li><li>Copies dependencies and built code from the builder stage.</li><li>Exposes port 3000 and specifies the CMD to run the application.</li></ul><p><strong>Testing Dockerfile</strong></p><p>We’ll test our docker files locally to ensure that everything works properly. Run this command to build the docker container</p><pre>docker build -t aws-test-backend .</pre><p>Run this command to start the docker container</p><pre>docker run -p 3000:3000 aws-test-backend</pre><p>When Docker runs without any errors, the logs will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jGQaURW7YabJvGiaymO0ng.png" /></figure><h4>3. Creating a Git repository</h4><p>To add your project to GitHub, make a git repository there and follow the guidelines.</p><h3>Travis CI configuration</h3><p>Travis CI (Continuous Integration) is a popular cloud-based service that automates the building, testing, and deployment of software projects hosted on GitHub. Travis CI uses a configuration file, commonly named .travis.yml, to define the build process and specify various settings. This file is written in YAML (YAML Ain&#39;t Markup Language), which is a human-readable data serialization format.</p><p><strong>Configuring Build and Deployment Scripts:</strong></p><pre>dist: bionic<br>language: node_js<br>node_js: &quot;18&quot;</pre><pre>services:<br>  - docker<br></pre><pre>branches:<br>  only:<br>    - main</pre><pre>before_install:<br>  - sudo apt-get install -y awscli</pre><pre>before_script:<br>  - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID<br>  - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY<br>  - aws configure set default.region $AWS_DEFAULT_REGION</pre><pre>jobs:<br>  include:<br>    - stage: Backend Deployment<br>      name: &quot;Run Backend Deployment&quot;<br>      script:<br>        - cd aws-test-backend<br>        - aws ecr get-login-password --region $AWS_DEFAULT_REGION| docker login --username AWS --password-stdin $AWS_ECR_DOCKER_REGISTRY<br>        - docker build -t $AWS_ECR_REGISTRY_NAME .<br>        - docker tag $AWS_ECR_REGISTRY_NAME:latest $AWS_ECR_DOCKER_REGISTRY/$AWS_ECR_REGISTRY_NAME:latest<br>        - docker push $AWS_ECR_DOCKER_REGISTRY/$AWS_ECR_REGISTRY_NAME:latest<br>      <br>      deploy:<br>        provider: elasticbeanstalk<br>        access_key_id: $AWS_ACCESS_KEY_ID<br>        secret_access_key: $AWS_SECRET_ACCESS_KEY<br>        region: $AWS_DEFAULT_REGION<br>        app: $AWS_ELASTIC_BEANSTALK_APP_NAME<br>        env: $AWS_ELASTIC_BEANSTALK_ENV_NAME<br>        bucket_name: $AWS_ELASTIC_BEANSTALK_BUCKET_NAME</pre><pre>        on:<br>          branch: main</pre><p><strong>GitHub Repository Linking with Travis CI</strong></p><ul><li>Log in to Travis CI using your GitHub account credentials.</li><li>Authorize Travis CI to access your GitHub repositories. This is usually done during the initial login process.</li></ul><p>Travis CI facilitates a smooth integration between your codebase and continuous integration processes by starting builds and deployments according to the configurations specified in the.travis.yml file.</p><p><strong>Adding AWS Credentials to Travis CI Environments</strong></p><ul><li>AWS_ACCESS_KEY_ID: AWS Access Key ID for authentication.</li><li>AWS_SECRET_ACCESS_KEY: AWS Secret Access Key corresponding to the provided Access Key ID.</li><li>AWS_DEFAULT_REGION:AWS region where your resources are located.</li><li>AWS_ECR_DOCKER_REGISTRY:AWS ECR (Elastic Container Registry) Docker registry URL. For example, 123456789012.dkr.ecr.us-east-1.amazonaws.com.</li><li>AWS_ECR_REGISTRY_NAME :Name for your Docker image.</li><li>AWS_ELASTIC_BEANSTALK_APP_NAME:AWS Elastic Beanstalk application name.</li><li>AWS_ELASTIC_BEANSTALK_ENV_NAME:AWS Elastic Beanstalk environment name.</li><li>AWS_ELASTIC_BEANSTALK_BUCKET_NAME:: AWS S3 bucket name where Elastic Beanstalk artifacts are stored.</li></ul><p>To add these, Go to your Travis CI project page. Under “More Options” go to settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9TzyQgs2kjbgb4hpPQjxg.png" /></figure><p>Under “Environment Variables,” add the above mentioned variables with their corresponding values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wik6cwiD8eMllfPauEMFkg.png" /></figure><p>Remember to keep your AWS credentials secure and avoid hardcoding them directly in your scripts or configurations. Use environment variables and encrypt sensitive information when possible.</p><h3>Testing Deployment Pipeline</h3><p>Now, that we have completed all the steps it is time to test our pipeline.</p><ul><li>Just make some changes in your code and push it to Git Hub repo using the following commands</li></ul><pre>git add .<br>git commit -m &quot;some changes&quot;<br>git push</pre><ul><li>Visit the Travis CI website (<a href="https://travis-ci.com/">https://travis-ci.com/</a>) and sign in with your GitHub account.</li><li>Access your repository’s dashboard to monitor the ongoing build triggered by the recent push.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERW1-R8exYKTfXVUXFeK4Q.png" /></figure><ul><li>Explore the build logs to identify any errors or issues.</li><li>After successful deployment logs will be look something like this.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lSYTqFm9jCDeYFOZfWhPbA.png" /></figure><ul><li>Navigate to Elastic Beanstalk and verify the event logs, which should display a successful message indicating that the environment update has been completed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cvb7j01Khc9yhUnC8dpgkA.png" /></figure><ul><li>“Click on the provided Domain link in the Environment overview. The backend is running successfully.</li></ul><h3>Conclusion</h3><p>This article provided a comprehensive guide for streamlining the deployment of a Nest.js backend on AWS using Travis CI. The key steps covered include setting up AWS, creating an Elastic Container Registry, configuring an Elastic Beanstalk environment, and developing a Nest.js application with Docker.</p><p>The Travis CI configuration covered essential elements like specifying the Linux distribution, Node.js version, and enabling Docker services. It also detailed the deployment script for pushing Docker images to Elastic Container Registry and deploying the application to Elastic Beanstalk.</p><p>Overall, this guide aimed to facilitate a smooth and automated deployment process for Nest.js applications on AWS using Travis CI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d3b5c128ec8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Calendar Event Email System in Nest.js with Nodemailer]]></title>
            <link>https://medium.com/@swetachauhan_46203/building-a-calendar-event-email-system-in-nest-js-with-nodemailer-9e8739803745?source=rss-bef46f2db74a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e8739803745</guid>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[calendar]]></category>
            <category><![CDATA[nodemailer]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[ical-generator]]></category>
            <dc:creator><![CDATA[Sweta Chauhan]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 19:43:55 GMT</pubDate>
            <atom:updated>2024-01-07T19:47:01.864Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>INTRODUCTION</em></h3><blockquote><em>In today’s fast-paced digital landscape, effective communication remains a cornerstone of successful applications and services. One crucial aspect is the ability to seamlessly integrate calendar events into your email system, providing users with timely and relevant information. In this article, we’ll explore how to achieve this using nest.js, Nodemailer. By the end, you’ll have a robust system in place for sending emails with embedded calendar events, enhancing user engagement and overall user experience. Let’s dive into the exciting world of building a Calendar Event Email System in Nest.js with Nodemailer.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*4Tgsk4jGf1AbQH4pGa6YUw.jpeg" /></figure><h4>Prerequisites</h4><p>Before proceeding, ensure that Node.js and npm are installed on your local machine. If not, download them from the official Node.js website at <a href="https://nodejs.org/">https://nodejs.org</a>.</p><h4>Creating a Custom Mail Service with Nodemailer and iCal-Generator in Your Project</h4><ol><li>Create a nestjs Project</li></ol><pre>nest new mail-project<br>cd mail-project</pre><h4><strong>1. Install Nodemailer modules</strong></h4><pre>npm install nodemailer<br>//or<br>yarn add nodemailer</pre><p><strong>2. Install ical-generator to define calendar events.</strong></p><pre>npm install ical-generator<br>//or<br>yarn add ical-generator</pre><p><strong>3. Create a custom mail service:</strong></p><ul><li>Use the following command to create a mail module</li></ul><pre>nest g resource mail</pre><ul><li>Configure SMTP transport on nodemailer in mailService file.</li></ul><pre>getTransporter() {<br>    return nodemailer.createTransport({<br>      host: process.env.SMTP_HOST,<br>      port: process.env.SMTP_PORT,<br>      secure: process.env.SMTP_TLS === &#39;yes&#39; ? true : false,<br>      auth: {<br>        user: process.env.SMTP_USERNAME,<br>        pass: process.env.SMTP_PASSWORD,<br>      },<br>    });<br>  }<br>  </pre><ul><li>Set a path and read .html file to retrieve a customized template. Add a function for fetching HTML templates.</li></ul><pre> async getTemplate(template: string) {<br>    const templateDir = join(__dirname, &#39;templates&#39;);<br>    const path = `${templateDir}/${template}.html`;<br><br>    const html = fs.promises.readFile(path, &#39;utf8&#39;);<br><br>    return html;<br>  }</pre><ul><li>Add a function to create a calendar event:</li></ul><pre> async createCalendarEvent() {<br>    const calendar = ical({ name: &#39;my first iCal&#39; });<br>    const startTime = new Date();<br>    const endTime = new Date();<br>    endTime.setHours(startTime.getHours() + 1);<br>    const createEvent = {<br>      start: startTime,<br>      end: endTime,<br>      location: &#39;Kolkata&#39;,<br>      organizer: {<br>        name: &#39;Sebastian Pekarek&#39;,<br>        email: &#39;abcd@gmail.com&#39;,<br>      },<br>      summary: &#39;Example Event&#39;,<br>      description: &#39;It works :)&#39;,<br>      url: &#39;http://sebbo.net/&#39;,<br>    };<br>    calendar.createEvent(createEvent);<br>    const iCalContent = calendar.toString();<br>    return iCalContent;<br>  }</pre><ul><li>Within the “templates” folder inside the mail module, create a new file named “default.html.” Customize its content to serve as your default email template.</li></ul><pre>&lt;!doctype html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;title&gt;Email Template&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;div<br>      style=&quot;<br>        font-family: &#39;Arial&#39;, sans-serif;<br>        padding: 20px;<br>        max-width: 600px;<br>        margin: auto;<br>      &quot;<br>    &gt;<br>      &lt;h1 style=&quot;color: #333&quot;&gt;Email Template&lt;/h1&gt;<br>      &lt;p style=&quot;color: #555&quot;&gt;Hi,&lt;/p&gt;<br>      &lt;p style=&quot;color: #555&quot;&gt;This is a default template.&lt;/p&gt;<br>      &lt;p style=&quot;color: #555&quot;&gt;Thanks,&lt;/p&gt;<br>    &lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>Write a function to send an email with a calendar event:</li></ul><pre>  async sendMail() {<br>    const html = await this.getTemplate(&#39;default&#39;);<br><br>    const iCalContent = await this.createCalendarEvent();<br>    const transporter = this.getTransporter();<br><br>    await transporter.sendMail({<br>      from: &#39;defaultmail@gmail.com&#39;, // sender address<br>      to: &#39;abc@gmail.com&#39;, // mail of receivers<br>      subject: &#39;Test mail&#39;,<br>      html: html,<br>      alternatives: {<br>        contentType: &#39;text/calendar; charset=&quot;utf-8&quot;; method=REQUEST&#39;,<br>        method: &#39;REQUEST&#39;,<br>        content: iCalContent,<br>      },<br>    });<br>    return {<br>      message: &#39;Mail sent successfully&#39;,<br>    };<br>  }</pre><ul><li>The final code will look like the following:</li></ul><pre>import { Injectable } from &#39;@nestjs/common&#39;;<br>import * as nodemailer from &#39;nodemailer&#39;;<br>import * as fs from &#39;fs&#39;;<br>import { join } from &#39;path&#39;;<br>import ical from &#39;ical-generator&#39;;<br>@Injectable()<br>export class MailService {<br>  async sendMail() {<br>    const html = await this.getTemplate(&#39;default&#39;);<br><br>    const iCalContent = await this.createCalendarEvent();<br>    console.log(iCalContent);<br>    const transporter = this.getTransporter();<br><br>    await transporter.sendMail({<br>      from: &#39;defaultmail@gmail.com&#39;, // sender address<br>      to: &#39;sweta@mollatech.com&#39;, // mail of receivers<br>      subject: &#39;Test mail&#39;,<br>      html: html,<br>      alternatives: {<br>        contentType: &#39;text/calendar; charset=&quot;utf-8&quot;; method=REQUEST&#39;,<br>        method: &#39;REQUEST&#39;,<br>        content: iCalContent,<br>      },<br>    });<br>    return {<br>      message: &#39;Mail sent successfully&#39;,<br>    };<br>  }<br><br>  async createCalendarEvent() {<br>    const calendar = ical({ name: &#39;my first iCal&#39; });<br>    const startTime = new Date();<br>    const endTime = new Date();<br>    endTime.setHours(startTime.getHours() + 1);<br>    const createEvent = {<br>      start: startTime,<br>      end: endTime,<br>      location: &#39;Kolkata&#39;,<br>      organizer: {<br>        name: &#39;Sebastian Pekarek&#39;,<br>        email: &#39;abcd@gmail.com&#39;,<br>      },<br>      summary: &#39;Example Event&#39;,<br>      description: &#39;It works :)&#39;,<br>      url: &#39;http://sebbo.net/&#39;,<br>    };<br>    calendar.createEvent(createEvent);<br>    const iCalContent = calendar.toString();<br>    return iCalContent;<br>  }<br><br>  async getTemplate(template: string) {<br>    const templateDir = join(__dirname, &#39;templates&#39;);<br>    const path = `${templateDir}/${template}.html`;<br><br>    const html = fs.promises.readFile(path, &#39;utf8&#39;);<br><br>    return html;<br>  }<br><br>  getTransporter() {<br>    return nodemailer.createTransport({<br>      host: process.env.SMTP_HOST,<br>      port: process.env.SMTP_PORT,<br>      secure: process.env.SMTP_TLS === &#39;yes&#39; ? true : false,<br>      auth: {<br>        user: process.env.SMTP_USERNAME,<br>        pass: process.env.SMTP_PASSWORD,<br>      },<br>    });<br>  }<br>}</pre><ul><li>In controller use the Get method to call the sendMail function:</li></ul><pre> @Get()<br>  sendMail() {<br>    return this.mailsService.sendMail();<br>  }</pre><ul><li>Now create a .env file in your project and add SMTP credentials</li></ul><pre>SMTP_USERNAME=user@default.works<br>SMTP_PASSWORD=&#39;**************&#39;<br>SMTP_HOST=smtp.gmail.com<br>SMTP_PORT=587</pre><ul><li>Start the server using the following command:</li></ul><pre>yarn start:dev</pre><ul><li>Upon successfully sending the email, you will receive a successful response</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b569OqbwP8YU7FHbPQrrzw.png" /></figure><ul><li>The recipient will then receive the final email with the following content:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b0B-0JPdG9nBL5TEmmqcUA.png" /></figure><h4>Conclusion</h4><p>This guide gives you the tools and know-how to smoothly add calendar events to your nest.js application. Now, you’re ready to create engaging emails with embedded calendars, taking your application to the next level.</p><p>The code for this tutorial is available on <a href="https://github.com/sweta-sks/mail-project.git">GitHub</a>.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e8739803745" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>