<?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 Mithun on Medium]]></title>
        <description><![CDATA[Stories by Mithun on Medium]]></description>
        <link>https://medium.com/@lmithun01?source=rss-1a65ca9b90ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bM8mj0nU4lIERK7-</url>
            <title>Stories by Mithun on Medium</title>
            <link>https://medium.com/@lmithun01?source=rss-1a65ca9b90ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:32:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lmithun01/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[Convert your Angular app into a high performance Progressive Web App (PWA)]]></title>
            <link>https://medium.com/@lmithun01/convert-your-angular-app-into-a-high-performance-progressive-web-app-pwa-1b484aca6f3a?source=rss-1a65ca9b90ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b484aca6f3a</guid>
            <dc:creator><![CDATA[Mithun]]></dc:creator>
            <pubDate>Tue, 04 Jun 2024 10:31:26 GMT</pubDate>
            <atom:updated>2024-06-04T10:31:26.083Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>Progressive Web Apps (PWAs) are web applications with native app-like capabilities, providing a seamless user experience. They can be installed with one click via an app manifest and offer improved startup performance through mechanisms like the application shell. This guide will walk you through converting a normal Angular app into a PWA using Angular’s service worker.</p><p>PWAs combine the best of web and mobile apps, allowing users to install them directly from the web. They provide features such as offline access, push notifications and background syncing, enhancing user engagement and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lP0PMOkmQpRUAnjCGuaftA.png" /></figure><p><strong>Converting a angular app into a pwa</strong></p><p><strong>Step 1:</strong> Install Angular Service Worker Package using npm</p><pre>npm install --save @angular/service-worker</pre><p><strong>Step 2: </strong>Activate the service worker in your angular.json file by adding the following properties under configurations</p><pre>&quot;configurations&quot;: {<br>  &quot;production&quot;: {<br>    &quot;buildOptimizer&quot;: true,<br>    &quot;serviceWorker&quot;: true,<br>    &quot;ngswConfigPath&quot;: &quot;src/ngsw-config.json&quot;<br>  }<br>}</pre><p><strong>Step 3: </strong>Create and configure `ngsw-config.json` which is a file specifying how the service worker should cache assets and data. Below is an example configuration.</p><pre>../src/ngsw.config.json<br><br>{<br>  &quot;index&quot;: &quot;/index.html&quot;,<br>  &quot;assetGroups&quot;: [<br>    {<br>      &quot;name&quot;: &quot;app&quot;,<br>      &quot;installMode&quot;: &quot;prefetch&quot;,<br>      &quot;resources&quot;: {<br>        &quot;files&quot;: [<br>          &quot;/favicon.ico&quot;,<br>          &quot;/index.html&quot;<br>        ],<br>        &quot;versionedFiles&quot;: [<br>          &quot;/*.bundle.css&quot;,<br>          &quot;/*.bundle.js&quot;,<br>          &quot;/*.chunk.js&quot;<br>        ]<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;assets&quot;,<br>      &quot;installMode&quot;: &quot;lazy&quot;,<br>      &quot;updateMode&quot;: &quot;prefetch&quot;,<br>      &quot;resources&quot;: {<br>        &quot;files&quot;: [<br>          &quot;/assets/**&quot;<br>        ]<br>      }<br>    }<br>  ]<br>}</pre><p><strong>Step 4 </strong>: Register the service worker in your Angular app by adding it to the @NgModule imports in app.module.ts</p><pre>import { ServiceWorkerModule } from &#39;@angular/service-worker&#39;;<br>import { environment } from &#39;../environments/environment&#39;;<br><br>@NgModule({<br>  imports: [<br>    // other imports<br>    ServiceWorkerModule.register(&#39;ngsw-worker.js&#39;, { enabled: environment.production })<br>  ]<br>})<br>export class AppModule { }</pre><p><strong>Step 5</strong>: To generate the production build with the service worker, run the below command</p><pre>ng build --prod</pre><p>The above command will create a dist folder containing the necessary files to be cached for your PWA.</p><p><strong>Contents of the dist folder:</strong></p><p>The dist folder contains the following key files:</p><ol><li><strong>ngsw-worker.js</strong>: The service worker script that will be installed in the user’s browser.</li><li><strong>ngsw.json</strong>: Configuration file that the service worker uses to manage caching and updates.</li></ol><p>To serve these files, use a simple HTTP server. Install the http-server package:</p><pre>npm i -g http-server</pre><p>Next, start the server using the installed http-server which also disables the caching headers and proxies API requests to your backend server.</p><pre>http-server -c-1 -P http://localhost:9000</pre><p><strong>Working of angular service worker:</strong></p><p>The Angular service worker acts as a network-level HTTP proxy. It intercepts requests and either forwards them to the network or serves them from the cache. This ensures that the app can load quickly and function offline.</p><p><strong>Managing multiple application versions:</strong></p><p>When a new version of the app is available, the service worker checks for updates. By default, the new version is downloaded in the background and activated on the next reload of the application. You can prompt users to reload the app immediately by using the SwUpdate service.</p><p><strong>Example of prompting application updates to user:</strong></p><p>In your app.component.ts, use the SwUpdate service to check for updates and prompt the updates to the user as shown below:</p><pre>import { SwUpdate } from &#39;@angular/service-worker&#39;;<br>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent {<br>  constructor(private swUpdate: SwUpdate) {<br>    if (this.swUpdate.isEnabled) {<br>      this.swUpdate.available.subscribe(() =&gt; {<br>        if (confirm(&#39;New version available. Load New Version?&#39;)) {<br>          window.location.reload();<br>        }<br>      });<br>    }<br>  }<br>}</pre><p><strong>Conclusion:</strong></p><p>Converting your Angular app to a PWA provides numerous benefits, including improved performance, offline capabilities, and a more engaging user experience. By following these steps, you can leverage Angular’s powerful tools to create a robust, installable web application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b484aca6f3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harnessing the Power of Web Components in Angular : Empowering Modern Web Development]]></title>
            <link>https://medium.com/sedin-technology/harnessing-the-power-of-web-components-in-angular-empowering-modern-web-development-aabe3adf8d89?source=rss-1a65ca9b90ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/aabe3adf8d89</guid>
            <dc:creator><![CDATA[Mithun]]></dc:creator>
            <pubDate>Thu, 18 Apr 2024 06:00:13 GMT</pubDate>
            <atom:updated>2024-04-18T06:15:28.509Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Harnessing the Power of Web Components in Angular</strong> : <strong>Empowering Modern Web Development</strong></h3><p><strong>Introduction:</strong></p><p>In the dynamic world of web development, Angular shines as a powerful framework for creating scalable web applications. As component-based architectures gain prominence, the integration of web components into Angular has become a compelling subject.</p><p>In this blog, we explore the synergy between Angular and web components, discussing their benefits, features, and steps to effortlessly integrate web component libraries into your Angular projects, backed by some real-time project experiences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/0*9t2uPDRxZMyWDVwm" /></figure><p><strong>Advantages of web components in angular:</strong><br><strong> </strong>Web components offer several advantages when integrated into Angular projects. They encapsulate HTML, CSS, and JavaScript into reusable custom elements, promoting code reusability and maintainability. Additionally, web components provide a clear separation of concerns, facilitating easier collaboration among team members. Moreover, leveraging web components in Angular enables interoperability with other frameworks and libraries, fostering a more versatile development ecosystem.</p><p><strong>Features of web components in angular :</strong></p><p>Web components consist of four main specifications:</p><p><strong>1) Custom Elements <br></strong> Custom Elements allow developers to define their own HTML elements, encapsulating functionality and styling within a single component.</p><p><strong>2) Shadow DOM<br></strong> Shadow DOM ensures encapsulation by providing a scoped DOM subtree for each component instance.</p><p><strong>3) HTML Templates<br> </strong>HTML Templates enable the creation of reusable markup fragments, enhancing code organization and readability.</p><p><strong>4) HTML Imports<br></strong> HTML Imports enable the inclusion of external HTML documents, facilitating modular development and dependency management.</p><p><strong>Using npm library as a web component in angular :</strong></p><ul><li>Install the desired web component library using npm or yarn</li></ul><pre>npm i library_name@version_number<br>npm i reflect-metadata</pre><ul><li>Add the entries in angular json file inside assets, scripts and styles like below</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EUS72a4RcywKFoOB" /></figure><ul><li>Import CUSTOM_ELEMENTS_SCHEMA in app module and add it to the NgModule as part of schemas like below</li></ul><pre>import {CUSTOM_ELEMENTS_SCHEMA} from &#39;@angular/core&#39;<br>....<br>@NgModule({<br>....<br>schemas: [CUSTOM_ELEMENTS_SCHEMA],<br>...<br>})</pre><ul><li>To integrate elements as a web component, create a viewChild in html template of the angular component.(Note that pdf is just a example name used below)</li></ul><pre>&lt;div #pdf&gt;&lt;/div&gt;</pre><ul><li>Refer the viewChild in ts file of the component and create the dom element for the library using document.createElement, then attach required configurations and since we are rendering using viewChild these steps should be under ngAfterViewInit hook of the angular component.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aPxOlTAEN9NOdjru" /></figure><p><strong>Conclusion:</strong></p><p>In conclusion, the integration of web components into Angular offers numerous benefits, including enhanced code reusability, maintainability, and interoperability.</p><p>Using npm libraries as a web component direct plugin makes our application independent of dependencies and versioning. As we continue to explore the synergies between Angular and web components, we envision a future where dynamic and scalable web applications are built with unparalleled efficiency and flexibility.</p><p>In the dynamic landscape of web development, the fusion of Angular and web components represents a paradigm shift towards modular and interoperable architectures. By embracing this synergy, developers can unlock new possibilities in creating robust and scalable web applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aabe3adf8d89" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sedin-technology/harnessing-the-power-of-web-components-in-angular-empowering-modern-web-development-aabe3adf8d89">Harnessing the Power of Web Components in Angular : Empowering Modern Web Development</a> was originally published in <a href="https://medium.com/sedin-technology">Sedin Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Mock Server for Seamless Development: A Guide for creating an api-mock]]></title>
            <link>https://medium.com/@lmithun01/building-a-mock-server-for-seamless-development-a-guide-for-creating-an-api-mock-637f3948d078?source=rss-1a65ca9b90ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/637f3948d078</guid>
            <dc:creator><![CDATA[Mithun]]></dc:creator>
            <pubDate>Thu, 25 Jan 2024 11:34:49 GMT</pubDate>
            <atom:updated>2024-01-29T03:59:34.917Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>In the dynamic realm of software development, the unavailability of a live server can pose significant challenges for developers and testers alike. Whether you’re in the early stages of development, working on a feature update, or rigorously testing your application, the reliance on a functioning server is undeniable. However, what happens when the actual server is temporarily out of reach?</p><p>This is where the role of mock servers comes into play. A mock server acts as a surrogate for the actual server, providing a simulated environment that allows developers to continue their work seamlessly, even when the real server is inaccessible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGWsDLppffRnUXJ8YEzvBg.png" /><figcaption>Visualizing Development Resilience</figcaption></figure><p><strong>Creating a node js application as a backend proxy api</strong></p><h3>Step 1 — Create a node js application</h3><p>Follow the steps in the “<a href="https://medium.com/@adnanrahic/hello-world-app-with-node-js-and-express-c1eb7cfa8a30">Create a nodejs application</a>” to create a node js application</p><h3>Step 2— Add and update the .env file</h3><p>Make a dotenv file the application which should have the contents as below</p><pre>PORT        =  3001<br>NODE_ENV.   =. development<br>TARGET_HOST =  &#39;https://example.com&#39;<br>PROXY_HOST  =  &#39;https://proxy-server.com&#39;</pre><p>TARGET_HOST =&gt; Actual server host url which will be serving the API&#39;s for the portal<br> PROXY_HOST =&gt; Proxy server host url which you have created to mock the response of specific API&#39;s/end-points (suggest to use postman mock-server)</p><h3>Step 3 — Create an environment and record the responses using postman</h3><p>Create a mock environment and record the responses for each and every apis using accurate urls ,required params and headers fetched from either dev or staging environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eve7-pHfxwUHaBpL6UkBRA.png" /></figure><h3>Step 4— Import the mock responses captured in postman</h3><p>Create and import the postman collection file into the app. Use this collection as a mock collection for Postman mock server. Mock the API that you want to as below</p><pre>curl --location &#39;https://dbcf2201-123f-4729-b5a5-0af277e92f7e.mock.pstmn.io/api/mock/v1/0135261634806579203&#39;</pre><h3>Step 5— Configure proxy host</h3><p>Take the Postman mock server URL after making all the necessary endpoints mock in it to configure for api-proxy-host in the env file</p><h3>Step 6— Sum up the api endpoints</h3><p>Add the mock endpoint into the nodeJS application’s config.js (PROXY_URLS) file.The config.js should look as below</p><pre>const PORT = process.env.PORT | 3001;<br>const TARGET_HOST = process.env.TARGET_HOST;<br>const PROXY_HOST = process.env.PROXY_HOST;<br>const PROXY_URLS =[<br>    &#39;list-of-api-endpoints-mocked&#39;,<br>]<br><br>module.exports = { PORT, TARGET_HOST, PROXY_HOST, PROXY_URLS }</pre><h3>Step 7— Run the application</h3><p>Run npm run start command in the root folder of the nodeJS application so that it runs on port 3001(default).</p><h3>Step 8— Use the mock server in the frontend</h3><p>Use this mock server for the frontend applications of portal by changing the fetching endpoint in their .env file or any other files based on structure.</p><pre>SB_DOMAIN=http://localhost:3001</pre><p><strong>Using a custom npm library as a proxy api:</strong></p><h3>Step 1 — Create a new directory and initialize npm</h3><p>Create a new directory in your local and initialize npm which sets up the package.json file in your app.Make sure to provide the necessary information, such as the package name, version, entry point, test command, and repository in there</p><pre>npm init</pre><h3>Step 2 —Export the mock data</h3><p>Create files representing the mock responses duplicated from the original api endpoint response, require them in the server.js and export them.</p><pre>const mock-data = require(&#39;./path-to-mock-response-file&#39;);<br><br>module.exports = {<br>  mock-data,<br>  //any other mocks<br>};</pre><h3>Step 3— Make server.js as the main file</h3><p>Mention the server.jsas the value to the main key in the package.json</p><pre>{<br>  &quot;name&quot;: &quot;mock-library-publish-name&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;&quot;,<br>  &quot;main&quot;: &quot;server.js&quot;,<br>  .......<br>}</pre><h3>Step 4— Login and publish the created library</h3><p>Create a npm account,login into npm and publish the created custom libary. The commands for login and publishing a library is given below.</p><pre>npm login<br>npm publish --access public</pre><h3>Step 5— Versioning the custom library</h3><p>When any changes are made to the library after publishing it,we should modify the version in the package.json and republish it.</p><pre>{<br>  &quot;name&quot;: &quot;mock-library-publish-name&quot;,<br>  &quot;version&quot;: &quot;1.1.0&quot;, //modified library version<br>  &quot;description&quot;: &quot;&quot;,<br>  &quot;main&quot;: &quot;server.js&quot;,<br>  .......<br>}</pre><p>The commnds for republishing the library is given below</p><pre>npm version &lt;new-version&gt;<br>npm publish --access public</pre><h3>Step 6— Versioning the custom library</h3><p>Install,import and use the custom created library in the frontend code.</p><pre>npm install &lt;library-name&gt;@&lt;version-number&gt;<br>import &#39;required-filename&#39; from &#39;library-name@version-number&#39;</pre><p><strong>Conclusion:</strong></p><p>In our exploration of mock servers and NPM libraries, we’ve uncovered a powerful solution to the common challenge of unavailability in development and staging servers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=637f3948d078" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>