<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pavan K Jadda</title>
    <description>The latest articles on DEV Community by Pavan K Jadda (@pavankjadda).</description>
    <link>https://dev.to/pavankjadda</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F385231%2F6001e996-333e-4949-bd19-627c0b6c40b0.jpeg</url>
      <title>DEV Community: Pavan K Jadda</title>
      <link>https://dev.to/pavankjadda</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pavankjadda"/>
    <language>en</language>
    <item>
      <title>How to save Hibernate Entity changes to Database</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Tue, 26 Dec 2023 06:38:03 +0000</pubDate>
      <link>https://dev.to/pavankjadda/how-to-save-hibernate-entity-changes-to-database-b8m</link>
      <guid>https://dev.to/pavankjadda/how-to-save-hibernate-entity-changes-to-database-b8m</guid>
      <description>&lt;p&gt;This post has been moved to &lt;a href="https://pavankjadda.dev/how-to-save-hibernate-entity-changes-to-database/"&gt;https://pavankjadda.dev/how-to-save-hibernate-entity-changes-to-database/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>hibernate</category>
      <category>mysql</category>
    </item>
    <item>
      <title>Schedule tasks in Spring Boot with @Scheduled annotation</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 06 Nov 2023 04:21:36 +0000</pubDate>
      <link>https://dev.to/pavankjadda/schedule-tasks-in-spring-boot-with-scheduled-annotation-12de</link>
      <guid>https://dev.to/pavankjadda/schedule-tasks-in-spring-boot-with-scheduled-annotation-12de</guid>
      <description>&lt;p&gt;The post has been moved to &lt;a href="https://pavankjadda.dev/scheduled-annotation-in-spring-boot/"&gt;https://pavankjadda.dev/scheduled-annotation-in-spring-boot/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>spring</category>
      <category>scheduled</category>
    </item>
    <item>
      <title>Dynamically Update Angular BASE URL Using Docker Env Variables</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 12 Sep 2022 19:22:46 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/dynamically-update-angular-base-url-using-docker-env-variables-3din</link>
      <guid>https://dev.to/playfulprogramming-angular/dynamically-update-angular-base-url-using-docker-env-variables-3din</guid>
      <description>&lt;p&gt;In Angular the BASE/API URLs are be stored environment files which are present under &lt;strong&gt;src/environments&lt;/strong&gt; directory. Usually we can create new file for each environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;environment.ts&lt;/li&gt;
&lt;li&gt;environment.dev.ts&lt;/li&gt;
&lt;li&gt;environment.test.ts&lt;/li&gt;
&lt;li&gt;environment.stage.ts&lt;/li&gt;
&lt;li&gt;environment.prod.ts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;environment.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import packageInfo from '../../package.json';

export const environment = {
    production: false,
    BASE_URL: '//localhost:4200',
    VERSION: packageInfo.version,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During the build, a configuration flag is provided to swap the default &lt;code&gt;environment.ts&lt;/code&gt; file with &lt;code&gt;environment.&amp;lt;CONFIGURATION&amp;gt;.ts&lt;/code&gt; based on the flag&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build -- --configuration=stage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem with this approach is you can't reuse same build for multiple environments and promote DEV to TEST then to STAGE eventually to PROD since BASE_URL is hard coded during build. To prevent this we need to replace the BASE_URL in &lt;code&gt;main.*.js&lt;/code&gt; file generated by Angular during the Docker container start up. &lt;/p&gt;

&lt;p&gt;First lets look at standard &lt;strong&gt;Dockerfile&lt;/strong&gt; that follows multi stage Dockerfile. To better understand this, refer my &lt;a href="https://dev.to/this-is-angular/multi-stage-docker-builds-with-angular-and-nginx-4j9d"&gt;other post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// See my other post for Build stage, so skipping it here

############  User Nginx alpine image  ############
FROM nginx:stable-alpine

# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*

# Copy nginx config file
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf

# Copy dist folder fro build stage to nginx public folder
COPY --from=builder /app/dist /usr/share/nginx/html

# Start NgInx services
CMD ["nginx", "-g", "daemon off;"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this we can add single that will update the BASE_URL during Docker container/service. Let's say out BASE_URL/API_URL is &lt;code&gt;employee-dev.example.com&lt;/code&gt;, then it can be replaced with UNIX &lt;code&gt;sed&lt;/code&gt; command as shown below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CMD sed -i "s/employee-dev.example.com/employee-$CONFIGURATION.example.com/g" /usr/share/nginx/html/main.*.js &amp;amp;&amp;amp; nginx -g 'daemon off;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the updated Dockerfile looks as below&lt;br&gt;
&lt;strong&gt;Dockerfile (Updated)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// See my other post for Build stage, so skipping it here

############  User Nginx alpine image  ############
FROM nginx:stable-alpine

# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*

# Copy nginx config file
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf

# Copy dist folder fro build stage to nginx public folder
COPY --from=builder /app/dist /usr/share/nginx/html

# Start NgInx services
CMD sed -i "s/employee-dev.example.com/employee-$CONFIGURATION.example.com/g" /usr/share/nginx/html/main.*.js &amp;amp;&amp;amp; nginx -g 'daemon off;'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you can start the container with Docker run command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 4000:80 -e CONFIGURATION=test &amp;lt;IMAGE_ID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;You can also use Docker ENTRYPOINT to achieve the same result. To do this using ENTRYPOINT, create new start.sh script file and copy the command. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;start.sh&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/sh
sed -i "s/employee-dev.example.com/employee-$CONFIGURATION.example.com/g" /usr/share/nginx/html/main.*.js
nginx -g 'daemon off;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and make sure to copy this file, make it executable and refer in ENTRYPOINT&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile (Updated with ENTRYPOINT)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;######  User Nginx alpine image  ######
FROM nginx:stable-alpine
ENV CONFIGURATION='dev'
# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*

# Copy nginx config file
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf

# Copy dist folder fro build stage to nginx public folder
COPY /dist /usr/share/nginx/html
COPY start.sh /usr/share/nginx/html
RUN chmod +x /usr/share/nginx/html/start.sh

# Start NgInx service
ENTRYPOINT ["./usr/share/nginx/html/start.sh", "$CONFIGURATION"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and start the container with Docker run command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 4000:80 -e CONFIGURATION=test &amp;lt;IMAGE_ID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;If you are not using Docker you can also same approach, since &lt;code&gt;sed&lt;/code&gt; is simple UNIX command&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>angular</category>
      <category>docker</category>
      <category>typescript</category>
    </item>
    <item>
      <title>How to fix ".gitignore not working" issue?</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 12 Sep 2022 04:41:36 +0000</pubDate>
      <link>https://dev.to/pavankjadda/how-to-fix-gitignore-not-working-issue-cch</link>
      <guid>https://dev.to/pavankjadda/how-to-fix-gitignore-not-working-issue-cch</guid>
      <description>&lt;p&gt;The post has been moved to &lt;a href="https://pavankjadda.dev/how-to-fix-gitignore-not-working-issue"&gt;https://pavankjadda.dev/how-to-fix-gitignore-not-working-issue&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
    </item>
    <item>
      <title>ngIf(Angular) and v-if (Vue) alternative in React</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Fri, 09 Sep 2022 23:37:45 +0000</pubDate>
      <link>https://dev.to/pavankjadda/ngifangular-and-v-if-vue-alternative-in-react-3l67</link>
      <guid>https://dev.to/pavankjadda/ngifangular-and-v-if-vue-alternative-in-react-3l67</guid>
      <description>&lt;p&gt;The post has been moved to &lt;a href="https://pavankjadda.dev/ngifangular-and-v-if-vue-alternative-in-react"&gt;https://pavankjadda.dev/ngifangular-and-v-if-vue-alternative-in-react&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>angular</category>
      <category>vue</category>
    </item>
    <item>
      <title>Angular URL State management with Query Params or Route Params</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Fri, 29 Jul 2022 05:37:00 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/angular-url-state-management-with-query-params-or-route-params-3mcb</link>
      <guid>https://dev.to/playfulprogramming-angular/angular-url-state-management-with-query-params-or-route-params-3mcb</guid>
      <description>&lt;p&gt;This blog post explains the process to maintain state using browser URL. In Angular there are couple of different ways to manage the state&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Angular Services&lt;/li&gt;
&lt;li&gt;State Management Library like NgRx, Akita, Elf etc.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But in some cases, you may want to share URL  and let others see the exact list of items (same order and filters applied). For example, when search for a flight in Travel website and find a good deal on certain dates, when you share the URL with your friend, for them it would load web page with default selection. But with URL state management, all changes are updated in URL and anyone using the URL would see the same selection.&lt;/p&gt;




&lt;h2&gt;
  
  
  Query Params vs Route Params
&lt;/h2&gt;

&lt;p&gt;This can be archived in one of the 2 ways&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Query Parameters&lt;/li&gt;
&lt;li&gt;Route Parameters&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Query Parameters are a defined set of parameters attached to the end of a url and follow the standard syntax, starts with "?" then each extra parameter followed by "&amp;amp;"&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://DOMAIN_NAME/employee/all?pageIndex=5&amp;amp;pageSize=10&amp;amp;sortDirection=asc&amp;amp;sortBy=salary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Route Parameters are similar Query Parameters except they only have single parameter separator like ";" and this can be changed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://DOMAIN_NAME/employee/all;pageIndex=5;pageSize=10;sortDirection=asc;sortBy=salary

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can use either one in your project. I typically gravitate towards Query Parameters since they are most common&lt;/p&gt;


&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;In this blog post we preserve angular materiel table sorting column, sorting order, page size, page index, search text etc.. selections in URL. When user goes to another page by clicking on URL and then later come back to the old page by clicking on browser back button, user will see same results. But this can also be applied to &lt;strong&gt;inputs, tables, tab selection&lt;/strong&gt; etc.&lt;/p&gt;

&lt;p&gt;As defined in this example, we have all-employees component that displays list of employees in Mat table. It supports following operations&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sorting&lt;/li&gt;
&lt;li&gt;Filtering&lt;/li&gt;
&lt;li&gt;Pagination&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h2&gt;
  
  
  Update the URL:
&lt;/h2&gt;

&lt;p&gt;The all employees component defines table data source, adds data, assigns paginator and sorter. See the complete component source code here. To store the user selections in the URL the &lt;code&gt;methodupdateRouteParameters()&lt;/code&gt; listens for all events on table&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
When user changes sorting order of a column, enters a filter text or changes page size or page index, this method updates the URL. And it will look like below&lt;br&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://DOMAIN_NAME/employee/all?pageIndex=5&amp;amp;pageSize=10&amp;amp;searchText=&amp;amp;sortDirection=asc&amp;amp;sortBy=salary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;if you want to use Route Parameters, you can make a small change in above code at line 15.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const urlTree = this.router.createUrlTree(['/employee/all',params]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;then URL becomes&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://DOMAIN_NAME/employee/all;pageIndex=5;pageSize=10;searchText=;sortDirection=asc;sortBy=salary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Load Webpage with Selected Options:
&lt;/h2&gt;

&lt;p&gt;After changing sorting, filtering, pagination options and reload the web page or opening this URL in different browser tab, should load the table with exact selections.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;mapTableData()&lt;/code&gt; method assigns data to table data source and formats table if any of the table options present in the URL.&lt;/p&gt;

&lt;p&gt;For example, when user access the link&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://DOMAIN_NAME/employee/all?pageIndex=5&amp;amp;pageSize=10&amp;amp;searchText=&amp;amp;sortDirection=asc&amp;amp;sortBy=salary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  the table should show 5th page with page size 10 sort by Salary column in Ascending order. To achieve this, we need to check for these parameters and modify the table data source.
&lt;/h2&gt;

&lt;p&gt;Code uploaded to &lt;a href="https://stackblitz.com/edit/angular-ivy-ecw17i?file=src/app/app.component.ts" rel="noopener noreferrer"&gt;Stackblitz&lt;/a&gt; for reference. Happy Coding :)&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Multi Stage Docker builds with Angular and Nginx</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Fri, 20 May 2022 18:44:03 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/multi-stage-docker-builds-with-angular-and-nginx-4j9d</link>
      <guid>https://dev.to/playfulprogramming-angular/multi-stage-docker-builds-with-angular-and-nginx-4j9d</guid>
      <description>&lt;p&gt;This blog post shows multi stage Dockerfile that builds and deploys Angular app in Nginx container&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
The above Dockerfile has 2 stages

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stage 1 - Install NPM dependencies and builds Angular project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stage 2 - Builds docker image from dist directory generated by previous stage&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Stage 1: Install dependencies and Build Angular project
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;We use Node 16 alpine image to build the project and it accepts CONFIGURATION build argument. You can override this during build based on your environment
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build --build-arg CONFIGURATION=dev .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and you can also define as many arguments as you like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Then make &lt;code&gt;/app&lt;/code&gt; as working directory. All of the source code and files will be copies to /app directory inside Node container
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WORKDIR /app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Copy the &lt;strong&gt;package.json&lt;/strong&gt; file to &lt;strong&gt;/app&lt;/strong&gt; directory. This will enable Docker to cache the node_modules rather than building from scratch and sub sequent builds use these when package.json file is unchanged.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY package.json .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Install dependencies using npm install command and specify flag &lt;code&gt;—-legacy-peer-deps&lt;/code&gt; to prevent build errors in NPM 7+
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN npm install --legacy-peer-deps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Then copy the source code and build the project using npm run build
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY . .
RUN npm run build --  --output-path=dist --configuration=$CONFIGURATION --output-hashing=all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;The built code will be present in &lt;code&gt;/app/dist&lt;/code&gt; directory in Node container&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Stage 2: Build Docker image
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We use NgInx alpine stable image to serve Angular application in production&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remove existing HTML content using the command&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN rm -rf /usr/share/nginx/html/*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Copy the Nginx config file from source to &lt;code&gt;/etc/nginx/nginx.conf&lt;/code&gt; directory. If you don’t have one, you can use the below one
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;/li&gt;

&lt;li&gt;Then Copy dist folder from build stage to nginx public folder
&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY — from=builder /app/dist /usr/share/nginx/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;At the end specify the NgInx start command. That’s it.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;You can also split Stage 1 into two separate stages. One to install dependencies and the second one to build the Angular app :)&lt;/p&gt;

</description>
      <category>angular</category>
      <category>docker</category>
      <category>nginx</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Unit and Integration test Spring Boot applications with Spring Testing and JUnit</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Thu, 23 Dec 2021 15:26:18 +0000</pubDate>
      <link>https://dev.to/pavankjadda/unit-and-integration-test-spring-boot-applications-with-spring-testing-and-junit-ebb</link>
      <guid>https://dev.to/pavankjadda/unit-and-integration-test-spring-boot-applications-with-spring-testing-and-junit-ebb</guid>
      <description>&lt;p&gt;The post has been moved to &lt;a href="https://pavankjadda.dev/unit-and-integration-test-spring-boot-applications-with-spring-testing-and-junit/"&gt;https://pavankjadda.dev/unit-and-integration-test-spring-boot-applications-with-spring-testing-and-junit/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>junit</category>
      <category>spring</category>
    </item>
    <item>
      <title>Angular SSR with Angular Universal and Deploy with Docker</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 11 Oct 2021 14:53:35 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/angular-ssr-with-angular-universal-and-deploy-with-docker-13i</link>
      <guid>https://dev.to/playfulprogramming-angular/angular-ssr-with-angular-universal-and-deploy-with-docker-13i</guid>
      <description>&lt;p&gt;This blog post explains the process to enable Angular Server Side Rendering(SSR) with Angular Universal and the process to deploy it in Docker container&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The source code of the application demonstrated in this post present in Github &lt;a href="https://github.com/pavankjadda/angular-ssr-docker" rel="noopener noreferrer"&gt;https://github.com/pavankjadda/angular-ssr-docker&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Setup Angular Application
&lt;/h2&gt;

&lt;p&gt;If you already have an existing Angular application, you can skip this step&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create new application
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ng new angular-ssr-docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add Angular material and
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng add @angular/material
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Import indigo-pink theme to application. Add following line to styles.scss
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import "~@angular/material/prebuilt-themes/indigo-pink.css";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create two components, Login and Home.
&lt;h2&gt;
  
  
  - When user logs in, it redirects him to home page
&lt;/h2&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Add Angular Universal
&lt;/h2&gt;

&lt;p&gt;Based on instructions from Angular docs,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add Angular Universal to the project
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng add @nguniversal/express-engine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and it will create the following folder structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/
  index.html                 app web page
  main.ts                    bootstrapper for client app
  main.server.ts             * bootstrapper for server app
  style.css                  styles for the app
  app/ ...                   application code
    app.server.module.ts     * server-side application module
server.ts                    * express web server
tsconfig.json                TypeScript base configuration
tsconfig.app.json            TypeScript browser application configuration
tsconfig.server.json         TypeScript server application configuration
tsconfig.spec.json           TypeScript tests configuration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;By default when you add Angular Universal to project Angular CLI creates &lt;strong&gt;projects/angular-ssr-docker/architect/serve-ssr&lt;/strong&gt; section in &lt;strong&gt;angular.json&lt;/strong&gt; with 2 configurations &lt;code&gt;development&lt;/code&gt; and &lt;code&gt;production&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;development&lt;/code&gt; configuration will be used when run &lt;code&gt;npm run dev:ssr&lt;/code&gt; and &lt;code&gt;production&lt;/code&gt; configuration will be user when you build application in production mode&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;See below snapshot of typical configuration. For some reason, if you can not start an application make change development section as below&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"configurations": {
  "development": {
    "browserTarget": "pdts:build",
    "serverTarget": "pdts:server",
    "proxyConfig": "src/proxy.conf.json"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fscsjhmib5onk4exhrvu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fscsjhmib5onk4exhrvu6.png" alt="Screen Shot 2021-10-11 at 10.13.45 AM" width="800" height="854"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you are like me, you can define additional configurations like dev, test as shown above&lt;/li&gt;
&lt;li&gt;Now, open terminal in the project and start JSON server (mocks backend)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;json-server - watch db.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open another terminal in same project and run the application
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev:ssr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="http://localhost:4200" rel="noopener noreferrer"&gt;http://localhost:4200&lt;/a&gt; to see the application in action&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Build Docker image
&lt;/h2&gt;

&lt;p&gt;Before building docker image, you need to build the application&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build the application with following command. Make sure to replace &lt;code&gt;--configuration=dev&lt;/code&gt; with appropriate profile name like &lt;code&gt;test&lt;/code&gt; or &lt;code&gt;production&lt;/code&gt; when you build the application for different environment
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ng build --configuration=dev &amp;amp;&amp;amp; sudo ng run pdts:server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add following &lt;strong&gt;Dockerfile&lt;/strong&gt; to build the docker image
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## Use Node Slim image
FROM node:14-slim

## Copy source code
COPY . .

## Start the application
CMD ["node", "dist/angular-ssr-docker/server/main.js"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Build Docker image with following command
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t angular_ssr_docker .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Run the image on port 4000(default). You can change to different by changing port flag -p 5001:4000
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 4000:4000 angular_ssr_docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="http://localhost:4000" rel="noopener noreferrer"&gt;http://localhost:4000&lt;/a&gt; to see the application in action&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;The source code of the application can be found in &lt;a href="https://github.com/pavankjadda/angular-ssr-docker" rel="noopener noreferrer"&gt;Github&lt;/a&gt;. Happy Coding :)&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>docker</category>
    </item>
    <item>
      <title>Safely Evolving Database with Liquibase, Spring Data, and Spring Boot</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 16 Aug 2021 20:15:50 +0000</pubDate>
      <link>https://dev.to/pavankjadda/safely-evolving-database-with-liquibase-spring-data-and-spring-boot-4p00</link>
      <guid>https://dev.to/pavankjadda/safely-evolving-database-with-liquibase-spring-data-and-spring-boot-4p00</guid>
      <description>&lt;p&gt;The post has been moved to &lt;a href="https://pavankjadda.dev/safely-evolving-database-with-liquibase-spring-data-and-spring-boot"&gt;https://pavankjadda.dev/safely-evolving-database-with-liquibase-spring-data-and-spring-boot&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>liquibase</category>
      <category>springboot</category>
      <category>springdata</category>
    </item>
    <item>
      <title>Synchronous HTTP calls in Angular using Async and Await</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 16 Aug 2021 20:14:07 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/synchronous-http-calls-in-angular-using-async-and-await-fdm</link>
      <guid>https://dev.to/playfulprogramming-angular/synchronous-http-calls-in-angular-using-async-and-await-fdm</guid>
      <description>&lt;p&gt;Observables in Angular offer significant benefits over other techniques for event handling, asynchronous programming, and handling multiple values. But some times we may want to wait for the response from previous HTTP call or load default settings for an application. In that case, we use Async and Await functions to achieve this. This blog post explains the steps and provides code samples. As usual complete code uploaded to &lt;a href="https://github.com/pavankjadda/Angular-Async-Await" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Async &amp;amp; Await
&lt;/h1&gt;

&lt;p&gt;An asynchronous function is a function that operates asynchronously via the event loop, using an implicit &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" rel="noopener noreferrer"&gt;Promise&lt;/a&gt; to return its result. But the syntax and structure of your code using async functions are much more like using standard synchronous functions. The &lt;code&gt;await&lt;/code&gt; operator is used to wait for a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" rel="noopener noreferrer"&gt;Promise&lt;/a&gt;. It can only be used inside an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function" rel="noopener noreferrer"&gt;async function&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async method()   
{  
  var x = await resolveAfter2Seconds(10);  
  console.log(x); // 10  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Technologies
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt; Angular 9+&lt;/li&gt;
&lt;li&gt; &lt;a href="https://github.com/typicode/json-server" rel="noopener noreferrer"&gt;&lt;strong&gt;json-server&lt;/strong&gt;&lt;/a&gt; (to mock Rest API)&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Synchronous HTTP call in Angular 9+
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;If you have Java, C# etc. backend available, skip the steps 1,2, 3 and go to step 4 directly&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;[**json-server**](https://github.com/typicode/json-server)&lt;/code&gt; helps to mock the backend REST API and stores entered data. In this application, we demonstrate a simple use case with two operations, create new employee and fetch a list of employees.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; First, create &lt;code&gt;db.json&lt;/code&gt; file, that holds employee information
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{  
 "employees":   
\[  
  {  
   "id": 1,  
   "firstName": "John",  
   "lastName": "Reese"  
  },  
  {  
   "id": 2,  
   "firstName": "Steve",  
   "lastName": "Rogers"  
  }  
 \]  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2. Add &lt;code&gt;json-server&lt;/code&gt; dependency and &lt;code&gt;json-server —- watch db.json&lt;/code&gt;  the script in &lt;strong&gt;package.json&lt;/strong&gt; as shown below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"dependencies":   
{     
  ....,      
  "json-server": "^0.14.2",  
  ....,},  
"scripts":   
{  
  ....,  
  "json-server": "json-server --watch db.json"  
  ....,  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3. start json-server by executing following command on the project root folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ json-server —-watch db.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4. Now that, backend mock REST API server is available, let’s build the front end. In order for async to work, both the component method and service method should annotate with &lt;strong&gt;async&lt;/strong&gt; and &lt;strong&gt;await&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  app.component.ts
&lt;/h1&gt;

&lt;p&gt;app.component.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;employee.service.ts&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;employee.service.ts&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; &lt;code&gt;createEmployee()&lt;/code&gt; method on component class annotated with &lt;code&gt;**async**&lt;/code&gt; and &lt;code&gt;employeeService.createEmployee()&lt;/code&gt; annotated with &lt;code&gt;**await**&lt;/code&gt;. This instructs the compiler to wait for the execution of &lt;code&gt;this.employeeService.createEmployee()&lt;/code&gt; method, then execute &lt;code&gt;this.getEmployees()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; &lt;code&gt;createEmployee()&lt;/code&gt; method on component class annotated with &lt;code&gt;**async**&lt;/code&gt; and &lt;code&gt;employeeService.createEmployee()&lt;/code&gt; annotated with &lt;code&gt;**await**&lt;/code&gt;. This instructs the compiler to wait for the execution of &lt;code&gt;this.employeeService.createEmployee()&lt;/code&gt; method, then execute &lt;code&gt;this.getEmployees()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;6. When you click on &lt;strong&gt;CreateNew&lt;/strong&gt; button on the HTML page, it creates a new employee with Random Id, then &lt;code&gt;this.getEmployees()&lt;/code&gt;  gets a list of employees&lt;/p&gt;

&lt;p&gt;The code uploaded &lt;a href="https://github.com/pavankjadda/Angular-Async-Await" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; for reference. Download the repository and execute it.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Synchronous and Asynchronous Data access using ThreadPoolExecutor and Spring Boot, Spring Data</title>
      <dc:creator>Pavan K Jadda</dc:creator>
      <pubDate>Mon, 16 Aug 2021 20:12:54 +0000</pubDate>
      <link>https://dev.to/pavankjadda/synchronous-and-asynchronous-data-access-using-threadpoolexecutor-and-spring-boot-spring-data-1k3g</link>
      <guid>https://dev.to/pavankjadda/synchronous-and-asynchronous-data-access-using-threadpoolexecutor-and-spring-boot-spring-data-1k3g</guid>
      <description>&lt;p&gt;The post has been moved to &lt;a href="https://pavankjadda.dev/synchronous-and-asynchronous-data-access-using-threadpoolexecutor-and-spring-boot-spring-data/"&gt;https://pavankjadda.dev/synchronous-and-asynchronous-data-access-using-threadpoolexecutor-and-spring-boot-spring-data/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
