<?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 Exclusive Technologies on Medium]]></title>
        <description><![CDATA[Stories by Exclusive Technologies on Medium]]></description>
        <link>https://medium.com/@exclusivetech.ch?source=rss-be2e669b1a4c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kG7D-u9tyxI0JjnU.jpg</url>
            <title>Stories by Exclusive Technologies on Medium</title>
            <link>https://medium.com/@exclusivetech.ch?source=rss-be2e669b1a4c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:08:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@exclusivetech.ch/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[Why We Decided to Let the AI Do the Talking (Without the Sci-Fi Hype)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@exclusivetech.ch/why-we-decided-to-let-the-ai-do-the-talking-without-the-sci-fi-hype-25891fee31c2?source=rss-be2e669b1a4c------2"><img src="https://cdn-images-1.medium.com/max/1344/1*4L2GVUf98iHzztA0IiLOcw.png" width="1344"></a></p><p class="medium-feed-snippet">After months of deep operational focus, we are restarting our communication through a transparent human-AI collaboration to share our&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@exclusivetech.ch/why-we-decided-to-let-the-ai-do-the-talking-without-the-sci-fi-hype-25891fee31c2?source=rss-be2e669b1a4c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@exclusivetech.ch/why-we-decided-to-let-the-ai-do-the-talking-without-the-sci-fi-hype-25891fee31c2?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/25891fee31c2</guid>
            <category><![CDATA[solutionsarchitect]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[enterprise-technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[b2b]]></category>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 14:06:01 GMT</pubDate>
            <atom:updated>2026-06-01T14:06:01.291Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[HttpOnly + SSR as a security boundary: keeping JWTs out of the frontend]]></title>
            <link>https://medium.com/@exclusivetech.ch/httponly-ssr-as-a-security-boundary-keeping-jwts-out-of-the-frontend-49ebf9550762?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/49ebf9550762</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[angular-21]]></category>
            <category><![CDATA[httponly]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 16:16:06 GMT</pubDate>
            <atom:updated>2025-12-15T16:16:06.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1GFwRHxD53Pqr74muVk_g.jpeg" /><figcaption>[Nano Banana] While I’m programming my app, I think of a fantastic sunset in the infinite space, hit by a storm of small meteorites as if they were data.</figcaption></figure><p><em>Disclaimer: this article was automatically translated/adapted with the help of an AI assistant from </em><a href="https://www.linkedin.com/pulse/httponly-ssr-come-confine-di-sicurezza-jwt-fuori-dal-frontend-pb4wf">httponly-ssr-come-confine-di-sicurezza-jwt-fuori-dal-frontend</a></p><h3>Why we’re writing this</h3><p>Over the last few days we came across and read this article (it explains the core problem really well):</p><p><a href="https://ganeshlawand2002.medium.com/the-secure-way-to-handle-jwt-authentication-in-angular-stop-using-localstorage-96e7be0d9b8c">https://ganeshlawand2002.medium.com/the-secure-way-to-handle-jwt-authentication-in-angular-stop-using-localstorage-96e7be0d9b8c</a></p><p>The key message is simple: <strong>storing JWTs in the browser (e.g., LocalStorage) creates real risk, especially under XSS</strong>. That aligns with a design decision we had already made: move authentication to <strong>HttpOnly cookies</strong> and keep JWT handling on the server side.</p><p>This pattern is already in production (at least in some of our applications), and since we don’t have much time — nor strong storytelling skills — we leaned on an “artificial” assistant to describe our approach in an orderly way, keeping the text as anonymous as possible and free from proprietary details.</p><p>When we build web apps with JWT-based authentication, the quickest path is often also the riskiest one: saving tokens in the browser and using them directly from client code.</p><p>In a recent project — an Angular app with SSR inside an Nx monorepo — we moved in a different direction: <strong>the frontend never “owns” JWTs</strong>. We use SSR as a security boundary, rely on <strong>HttpOnly cookies</strong>, and leave the entire JWT lifecycle to a remote backend.</p><p>This post is intentionally anonymous and not tied to a single implementation. It focuses on the pattern, not on proprietary details.</p><p>Small disclaimer: we don’t consider this “the only right way” in absolute terms. As with most security work, it depends on the threat model, domain constraints, and infrastructure. Here we’re sharing what has been working well for us and why.</p><h3>TL;DR</h3><ul><li>We avoid exposing JWTs to the browser (no localStorage, no sessionStorage, no JS-readable cookies).</li><li>We keep only an <strong>HttpOnly session cookie</strong> (or equivalent) at the edge/SSR boundary.</li><li>JWT creation/refresh/validation happens <strong>only</strong> in the remote backend.</li><li>From the very first request, SSR <strong>forwards session context</strong> (e.g., auth_token / x-jwt-session) to backend APIs.</li><li>Our “first page” acts as a <strong>gateway</strong> that can be separated from the main app and, later, enforced at the proxy layer (Nginx/Apache/Envoy).</li></ul><h3>The problem we wanted to address</h3><p>We needed authentication that:</p><ul><li>Reduced the impact of XSS (because tokens aren’t accessible to JavaScript).</li><li>Centralized JWT logic in one place (the backend), so frontend releases don’t turn into “security releases.”</li><li>Worked well with SSR and stayed compatible with future infrastructure evolution (reverse proxies, WAF, edge filtering).</li></ul><p>At the same time, we wanted a realistic developer experience:</p><ul><li>SSR must be able to render personalized content when the user is authenticated.</li><li>Client-side navigation should remain fast.</li><li>API calls should be authenticated consistently.</li></ul><h3>Design principle: “frontend as a view, backend as the authority”</h3><p>We try to treat the browser UI as a rendering surface, while keeping authentication authority on the server.</p><p>In practice:</p><ul><li>The browser never receives a JWT.</li><li>The browser only carries session context in an HttpOnly cookie.</li><li>The SSR layer and/or backend uses that context to obtain/validate JWTs.</li></ul><p>This is less about frameworks and more about <strong>where we decide trust should live</strong>.</p><h3>The HttpOnly pattern (why it matters)</h3><p>An HttpOnly cookie:</p><ul><li>Is automatically sent by the browser on requests to the correct origin/path.</li><li>Cannot be read by JavaScript (reducing token exfiltration in case of XSS).</li><li>Can be paired with Secure and SameSite policies for better baseline hardening.</li></ul><p>The key outcome is simple:</p><blockquote><em>Even if someone injects JavaScript into the page, they can’t directly read the token.</em></blockquote><p>It doesn’t make XSS “safe,” but it tends to reduce a common high-impact failure mode: <strong>token theft and replay</strong>.</p><h3>Request flow: from the first page onward</h3><p>We structured the app so that the <em>first meaningful request</em> acts as a gatekeeper.</p><h3>1) The user hits the entry point</h3><ul><li>The user loads an SSR-served page.</li><li>If a session cookie is present, SSR can treat the user as potentially authenticated.</li><li>If it’s missing (or invalid), SSR can redirect to login or render a “not authenticated” state.</li></ul><h3>2) SSR forwards session context to the backend</h3><p>On SSR outbound calls (e.g., user profile, roles, navigation, initial data), we forward a minimal context header, for example:</p><ul><li>auth_token <em>(session identifier, not a JWT)</em></li><li>x-jwt-session <em>(session handle, not a JWT)</em></li></ul><p>Names matter less than the principle:</p><blockquote><em>SSR forwards </em><strong><em>session context</em></strong><em>, and the backend decides what it means.</em></blockquote><h3>3) The backend owns the JWT lifecycle</h3><p>The remote backend is responsible for:</p><ul><li>Creating JWTs.</li><li>Renewing/refreshing JWTs.</li><li>Validating JWTs.</li><li>Mapping sessions to identities/roles/claims.</li></ul><p>In the frontend we keep <strong>no code</strong> that parses/refreshes/signs JWTs.</p><p>In general, we try to keep this responsibility in one place: it reduces mistakes and divergent behavior.</p><h3>4) Client navigation stays simple</h3><p>After the initial SSR render:</p><ul><li>Client-side navigation continues as usual.</li><li>Client-side data fetching can call an SSR/API layer that already knows how to attach session context (or it can rely on the cookie being automatically sent, depending on the topology).</li></ul><h3>Why we like the “gateway first page” approach</h3><p>We intentionally treat the entry point as a gateway. In practice:</p><ul><li>It can live outside the main app’s routing tree.</li><li>It can be separated into a minimal surface area responsible only for session validation and safe redirects.</li></ul><p>This sets us up for the next step.</p><h3>Future step: enforcement at the proxy layer</h3><p>When we add infrastructure like Nginx/Apache/Envoy (or a managed gateway), we can push enforcement outward:</p><ul><li>If a request isn’t authenticated, the proxy blocks it before it reaches the app.</li><li>Only authenticated traffic can reach SSR or specific route prefixes.</li></ul><p>That gives us a clean separation:</p><ul><li><strong>Proxy/gateway</strong>: coarse access control, routing, baseline hardening.</li><li><strong>Backend</strong>: identity, authorization, JWT logic.</li><li><strong>SSR/frontend</strong>: rendering and user experience.</li></ul><h3>Practical notes and tradeoffs</h3><p>This pattern isn’t “free.” We accepted a few tradeoffs:</p><ul><li><strong>SSR becomes security-sensitive code</strong>: we keep it lean, review it carefully, and avoid unnecessary dependencies.</li><li><strong>Cookie policies matter</strong>: domain/path/samesite/secure must be correct.</li><li><strong>CSRF strategy must be explicit</strong>: HttpOnly cookies help, but we still need a plan (e.g., SameSite + CSRF tokens for state-changing operations, depending on the architecture).</li><li><strong>Observability is important</strong>: authentication failures should be traceable across SSR and backend.</li></ul><p>The main benefit, for us, is that the browser doesn’t hold the keys.</p><h3>A lightweight checklist we use</h3><ul><li>[ ] No JWTs in browser storage.</li><li>[ ] No JS-readable auth cookies.</li><li>[ ] SSR forwards only session context headers.</li><li>[ ] The backend is the only component that signs/refreshes/validates JWTs.</li><li>[ ] The entry point acts as a gateway (redirect/deny early).</li><li>[ ] Clear path toward proxy-level enforcement (route-level isolation).</li></ul><h3>Closing thoughts</h3><p>From our experience, treating SSR as a boundary — and keeping JWT handling entirely on the backend — can simplify the security posture and make the frontend codebase calmer.</p><p>We don’t need refresh logic in the client, we avoid exposing credentials to JavaScript, and we can progressively move enforcement toward dedicated infrastructure (gateway/proxy).</p><p>Thank you for taking the time to read this … and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/367/1*kE6GJvBfqCbLZh3ufAUE1w.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49ebf9550762" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security Update: TOTP, TEvent, and Testing Antigravity!]]></title>
            <link>https://medium.com/@exclusivetech.ch/security-update-totp-tevent-and-testing-antigravity-1b2205ca1e36?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b2205ca1e36</guid>
            <category><![CDATA[angular-21]]></category>
            <category><![CDATA[tevent]]></category>
            <category><![CDATA[totp]]></category>
            <category><![CDATA[antigravity]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 18:15:10 GMT</pubDate>
            <atom:updated>2025-11-24T18:15:10.939Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jIG7Y3HAeUa8PQBMUkK1BQ.png" /><figcaption>thoughts that fly without gravity in my study</figcaption></figure><p>Over the last weekend, we decided to add a significant new feature to our management application.</p><p>Up until now, we have used our own internal system for user authentication, a hybrid approach combining a password with a server-generated OTP confirmation. To increase security, we decided to start using TOTP (Time-based One-Time Password), allowing for external authenticators such as Google Authenticator, Authy, Microsoft Authenticator, etc.</p><p>It is still in the testing phase, but the implementation is functional and operational. From within the management application, an enabled user can choose which pre-registered user to send an email to, containing a link to load the QR code for registration with the external authentication app. The link used for registration is valid for 10 minutes, and only once.</p><p>Once the QR code is registered, the user can use the external authentication app to generate TOTP codes, valid for 30 seconds, to be used during the login phase.</p><p>The TEvent pattern, which we have already described in previous posts, allowed us to integrate this new functionality without modifying the existing login flow. This enabled us to run the new feature alongside the old one for testing, without impacting existing users. We added new user interfaces and new backend functions, but without changing the way requests and responses occur between backend components and microservices.</p><p>Our Experience with Google Antigravity</p><p>For this new functionality, we specifically wanted to use Google Antigravity.</p><p>We are neither testers nor sponsored influencers (we wish!), but simple developers — and not even the most experienced ones.</p><p>Our main question was: “This is great, but… how does it work in an existing project?” Videos and documentation are mostly focused on new projects, starting from scratch. What if your project isn’t about selling flowers online or booking airline tickets?</p><p>We are not in a position to give an absolute judgment, but the initial impression was positive. As a first impression, we did not experience any particular slowdowns or integration issues. Our project has so far been developed with Visual Studio Code and Copilot; the integration with Google Antigravity was quick and straightforward, utilizing the configurations within Studio Code. By connecting remotely, it loaded the different workspaces, and since we don’t use proprietary extensions, we had no compatibility issues with our Open VSX extensions.</p><p>Overall, considering this is a first version with all its limitations, we never needed to reopen the project with Visual Code to fix integration issues.</p><p>In conclusion, the impression was positive, for what our limited experience is worth.</p><p>We plan to try using it soon to develop a web project from scratch, to further test the offered functionalities without risking an impact on the existing project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b2205ca1e36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TEvent-Driven Frontend-Backend: a single, unified way to communicate.]]></title>
            <link>https://medium.com/@exclusivetech.ch/tevent-driven-frontend-backend-a-single-unified-way-to-communicate-3b19845e9d63?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b19845e9d63</guid>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 13:38:27 GMT</pubDate>
            <atom:updated>2025-11-12T13:38:27.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T6j9zlPMvwFNFXOlTKPGmw.png" /></figure><p>Note: this technical article was drafted with the help of AI tools. We are not copywriters: we use AI to explain our work clearly and quickly; the technical decisions described remain ours.</p><p>As written in previous articles:</p><ul><li><a href="https://medium.com/@exclusivetech.ch/from-event-to-tevent-a-pattern-to-unify-angular-and-backend-502e9a32d447">From Event to TEvent: A Pattern to Unify Angular and Backend</a></li><li><a href="https://medium.com/@exclusivetech.ch/evolution-of-the-tevent-pattern-in-our-platform-4757c6cb56d2">Evolution of the TEvent pattern in our platform</a></li></ul><p>In recent months we have evolved our internal framework by moving the core of communication to TEvent + gRPC. Previously the pattern lived almost exclusively in the GUI layer; now the event is the universal language between frontend and backend. No “classic” generic REST API, no complicated endpoints: every interaction is a structured TEvent.</p><p>At the moment this architecture, although still evolving, is already running in production.</p><h3>Why TEvent</h3><p>A TEvent contains identifiers (eventID, cid, etarget, eaction) and a serialized datapl payload. It’s a consistent envelope that enables:</p><ul><li>End-to-end tracking</li><li>Reduced semantic ambiguity</li><li>Native instrumentation and auditing</li></ul><h3>The role of gRPC</h3><p>We chose gRPC for:</p><ul><li>Explicit contracts (protobuf = clear schema, governed versioning)</li><li>Performance (HTTP/2 + binary framing)</li><li>Streaming where needed (event push / orchestration) REST remains too permissive; “free” JSON increases alignment debt. Here the contract is central, not derived.</li></ul><h3>Backend components</h3><ul><li>grpc-main: orchestrator. Receives TEvent, resolves the route, coordinates data-access and procedures.</li><li>tdata-psql: parameterized layer. Executes only precomposed statements / safe templates; the frontend does not send raw SQL, so no injection.</li><li>trpc-exec: invokes dynamic Go routines (processing, enrichment, transformations). Isolation to extend without bloating the orchestrator.</li></ul><p>TEvent travels through these blocks unchanged as the “lingua franca.” Each service reads the metadata and only operates on the payload when it’s within its domain.</p><h3>Frontend components (Nx + Analog/Angular)</h3><ul><li>Angular app on Analog (SSR/ISR-ready), Nx monorepo.</li><li>State management: NGXS as the single store for intent/result; tracing via cid/eventID in the envelope.</li><li>gRPC-web client: types generated from protobuf, no manual mapping. Centralized TEvent builder (enrichment: cid, timestamp, actor).</li><li>Event dispatcher: translates UI intent → TEvent → gRPC; handles ResultEvent (success, validation, domain errors) with notifications/UX (toast, banner).</li><li>Feature-first: vertical modules (bounded context) that declare supported etarget/eaction; validators co-located with the domain.</li><li>Security by design: no “free” SQL/proc from the client; only validated parameters sent in datapl.</li></ul><p>End-to-end flow (at a glance): [GUI] → (TEvent Builder) → [Store/NGXS] → (gRPC-web) → [grpc-main] → [tdata-psql | trpc-exec] → (ResultEvent) → [Store/UX]</p><h3>DevX and Nx monorepo</h3><ul><li>Nx workspace: shared libraries (tevent-core, validators, grpc-client), internal generators for handler/feature scaffolding.</li><li>Type-safety: protobuf → coherent TS/Go types.</li></ul><h3>Security and maintenance</h3><p>Removing arbitrary query composition on the client side eliminated an entire class of risks. Standardizing the event made observability easier (structured logs, correlation by cid / eventID). Refactoring and adding features now means adding new handlers, not modifying a monolith of endpoints.</p><h3>Trade-offs</h3><ul><li>Higher initial complexity (protobuf definition, generators, naming discipline).</li><li>JSON in the payload instead of nested protobuf for evolutionary flexibility (we accept slight overhead for iteration speed).</li><li>Requires a rigorous contract culture (no “quick patch” outside the schema).</li></ul><p>The upside: end-to-end type-safety, faster onboarding, reduced impact of schema changes.</p><h3>What’s next</h3><p>The frontend layer integrates the TEvent → dispatch → store (state management) → gRPC flow directly. This enables functional tracing across the whole flow. Next steps: consolidate SSR with Analog, introduce a schema registry for datapl, Nx generators for validators, progress event streaming for reactive UX.</p><p>It’s probably not the perfect architecture, but it’s a scheme that, refined and expanded over time, has allowed us to maintain good consistency and make communication between functional layers — frontend to backend — almost transparent.</p><h3>Thank you for taking the time to read this</h3><p>… and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/245/0*Se0CSyq0RTozZS9R.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b19845e9d63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evolution of the TEvent Pattern in Our Platform]]></title>
            <link>https://medium.com/@exclusivetech.ch/evolution-of-the-tevent-pattern-in-our-platform-4757c6cb56d2?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4757c6cb56d2</guid>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Thu, 09 Oct 2025 17:01:29 GMT</pubDate>
            <atom:updated>2025-10-09T17:01:29.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6c9qRRJFJuqETObDyjXkg.png" /><figcaption>make the image sharper and the mountain, with the snow, is like an island in the Caribbean Sea</figcaption></figure><p>After <a href="https://medium.com/@exclusivetech.ch/from-event-to-tevent-a-pattern-to-unify-angular-and-backend-502e9a32d447">From Event to TEvent: A Pattern to Unify Angular and Backend</a> we continued refactoring our application to solidify the pattern across communication flows between the frontend (Angular/AnalogJS) and the backend services in Go and Node.js. The goal is to minimize the traditional REST surface and adopt gRPC as the primary channel.</p><p>Over the past few days we have started using this version in a semi-production phase: the behavior is stable, and we are collecting feedback to complete the remaining open tasks.</p><h3>Adoption Status of the Pattern</h3><p>At this stage we are focusing on a subset of TEvent&lt;T&gt;:</p><pre>interface TEvent&lt;T&gt; {<br>    cid: CID;        // Event originator<br>    etarget: CID;    // Intended recipient<br>    eaction: Action; // Desired action<br>    datapl: T;       // Payload<br>}</pre><p>Our main focus is on datapl: T, used within a structure like the following:</p><pre>{<br>    &quot;tdata&quot;: &quot;data type&quot;,<br>    &quot;queryf&quot;: &quot;myquery or&quot;,<br>    &quot;procf&quot;: &quot;myprocedure&quot;,<br>    &quot;qaction&quot;: &quot;[what] To Do&quot;,<br>    &quot;nextaction&quot;: &quot;[what] To Do on response&quot;,<br>    &quot;qpars&quot;: [<br>                // always present <br>         {<br>            &quot;name&quot;: &quot;User&quot;,<br>            &quot;type&quot;: &quot;text&quot;,<br>            &quot;value&quot;: &quot;myuser&quot;<br>        },<br>        {<br>            &quot;name&quot;: &quot;par1&quot;,<br>            &quot;type&quot;: &quot;text&quot;,<br>            &quot;value&quot;: &quot;val1&quot;<br>        },<br>        ...<br>        {<br>            &quot;name&quot;: &quot;parN&quot;,<br>            &quot;type&quot;: &quot;typeN&quot;,<br>            &quot;value&quot;: &quot;valN&quot;<br>        }<br>    ]</pre><p>This approach lets us rationalize the number of endpoints and keeps the responsibility for describing the desired action within the application, while the backend interprets and handles the requests.</p><h3>The gRPC Contract</h3><p>We describe the interactions through a minimal protobuf that simulates an API call:</p><pre>message RequestResponse {<br>    // e.g. &quot;GET&quot; or &quot;POST&quot; or any other string<br>	string method = 1;<br>    // full path, e.g. &quot;like/api/my/end/point&quot;<br>	string path = 2;<br>	// JSON payload for requests or empty<br>	string teventdatapljsonstring = 3;<br>}</pre><p>Within this schema:</p><ul><li>method describes the request type whenever we need to distinguish between operations.</li><li>path helps route the call to the correct logic block (authentication, data, and so on).</li><li>teventdatapljsonstring contains the JSON payload of the TEvent&lt;T&gt; event, useful both for processing and for wrapping the response.</li></ul><p>This structure allows us to include metadata such as authentication-token management while keeping the payload consistent with what happens on the frontend.</p><h3>Migrating the Backend Architecture</h3><p>One of the most significant refactoring goals was to replace Redis with a specialized Go application orchestrated via gRPC. Thanks to the TEvent&lt;T&gt; pattern we were able to route the same information blocks both to the new services and to the existing ones, minimizing the risk of regressions and smoothing the transition.</p><p>From the very first versions our app took an unconventional approach to REST APIs: just a handful of generic endpoints capable of interpreting descriptive requests from the app. The current refactoring reinforces this choice, giving us a more linear, observable communication flow.</p><h3>External Feedback and Confirmation</h3><p>We chose this direction primarily on the back of the experience we’ve accumulated over the years. Today we found an interesting validation in the article <a href="https://medium.com/@neerupujari5/why-i-stopped-using-json-and-started-using-protocol-buffers-c581923f4142">Why I Stopped Using JSON and Started Using Protocol Buffers</a>, which lays out arguments very close to our own assessments. It’s not a definitive proof, but it’s encouraging to see a perspective that aligns with ours.</p><h3>Acknowledgments</h3><p>We want to thank everyone who uses the application day in and day out and who, during this transition, patiently handled delays and interruptions, aware that the entire company was waiting to resume each time. A word of thanks also goes to AI, which helped us accelerate development: we would probably have reached the same point, though not as quickly. We’ll keep improving the project and making our communication increasingly clear and professional.</p><h3>Thank you for taking the time to read this</h3><p>… and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/245/0*QowOXIqUM_OirkRe.png" /></a></figure><p><strong>#Angular #Golang #EventDriven #SoftwareArchitecture #TypeScript #NgRx #gRPC #AI</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4757c6cb56d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Event to TEvent: A Pattern to Unify Angular and Backend]]></title>
            <link>https://medium.com/@exclusivetech.ch/from-event-to-tevent-a-pattern-to-unify-angular-and-backend-502e9a32d447?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/502e9a32d447</guid>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 15:38:41 GMT</pubDate>
            <atom:updated>2025-06-12T15:38:41.712Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeE-j38QN2uikRXp-ekf4g.png" /><figcaption>From home to infinite possibilities. Technology transforms perspective, yet nature continues to inspire.<strong>#Angular #Golang</strong></figcaption></figure><p><strong>Subtitle:</strong> <em>How we simplified communication between Angular frontend and Go microservices with an event-driven approach</em></p><blockquote><strong><em>English version:</em></strong><em> automatic translation from original Italian version on </em><a href="https://www.linkedin.com/pulse/da-event-tevent-un-pattern-per-unificare-angular-e-backend-hxise"><em>linkedIn</em></a></blockquote><blockquote><strong><em>Transparency note:</em></strong><em> For lack of time and, let’s admit it, a bit of laziness 😅, this text was generated with the help of artificial intelligence. I’m not that good at writing.</em></blockquote><h3>The Context</h3><p>Developing Angular applications with Go backends, we often found ourselves managing three different “dialects”:</p><ul><li>🅰️ <strong>NgRx Actions</strong> for state management</li><li>🌐 <strong>HTTP/gRPC calls</strong> for APIs</li><li>🔄 <strong>Message passing</strong> between Go microservices</li></ul><p>Each layer had its own syntax, its own conventions. It worked, but… it wasn’t elegant.</p><h3>The Simple Idea</h3><p>What if we used <strong>the same “building block”</strong> everywhere? An event that speaks Angular as much as Go, that travels from button click to database maintaining the same structure.</p><p>Thus TEvent&lt;T&gt; was born - not to reinvent the wheel, but to <strong>standardize the language</strong>.</p><h3>The Base Structure</h3><pre>// A simple but powerful contract:<br>interface TEvent&lt;T&gt; {<br>  cid: CID;        // Who generates the event<br>  etarget: CID;    // Who should receive it  <br>  eaction: Action; // What should happen<br>  datapl: T;       // The transported data<br>}</pre><p><strong>Same event, three contexts:</strong></p><ul><li>Angular component → NgRx store</li><li>Angular service → Go backend</li><li>Go service → Go service</li></ul><h3>The Practical Benefits</h3><p>After over 5 years of production use, here’s what we noticed:</p><p><strong>🎯 Simplified debugging</strong>: Same format from frontend to backend logs<br><strong>🔄 Safe refactoring</strong>: Change the logic, not the contract<br><strong>🧪 Uniform testing</strong>: Mock once, test everywhere<br><strong>📈 Fast onboarding</strong>: New developer, only one pattern to learn</p><h3>The gRPC/trpc Extension</h3><p>The TEventGrpc&lt;T&gt; class adds only what&#39;s needed:</p><ul><li>Endpoint type (GET/POST/WS)</li><li>Destination URL</li><li>Automatic serialization</li></ul><p>Angular sends a TEvent, Go receives a TEvent. No mapping, no transformations.</p><h3>It’s Not All Perfect</h3><p>There are open challenges:</p><ul><li>Event versioning management</li><li>Optimal cross-platform serialization</li><li>Performance with complex payloads</li><li>Integration with existing systems</li></ul><h3>Next Steps</h3><p>In the coming weeks I’ll share:</p><ul><li>Practical Angular ↔ Go implementation</li><li>Patterns for event history and debugging</li><li>Error handling and automatic retry</li><li>Concrete usage examples</li></ul><h3>A Reflection</h3><p>I don’t claim to have solved all software architecture problems. It’s simply an approach that, in our context, brought more order and less complexity.</p><p>Maybe it can be useful as inspiration.</p><h4>Thank you for taking the time to read this</h4><p>… and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/245/1*i6pS5eeLLFnSTVTWhjI9ZA.png" /></a></figure><p><strong>#Angular #Golang #EventDriven #SoftwareArchitecture #TypeScript #NgRx #gRPC #AI</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=502e9a32d447" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indesign UXP script]]></title>
            <link>https://medium.com/@exclusivetech.ch/indesign-uxp-script-852764c93689?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/852764c93689</guid>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 19:32:40 GMT</pubDate>
            <atom:updated>2025-04-11T20:41:05.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVeSEQDMQo0UCGgFR73XrA.png" /><figcaption>[firefly]:panorama with soft desert dunes with an oasis like mirage in the background</figcaption></figure><p>Translated from <a href="https://www.linkedin.com/pulse/indesign-uxp-script-drservice-it-bcchf">Indesign UXP script</a> by <a href="https://www.linkedin.com/company/drservice-it/">DrService.it</a></p><p>In <a href="https://www.linkedin.com/pulse/latex-docker-container-per-modulistica-drservice-it-naqtf?trackingId=%2BubbYO3WF2Y2%2FgOUNxZVdg%3D%3D&amp;lipi=urn%3Ali%3Apage%3Ad_flagship3_company_admin%3BbtH1yOZzSkediFJHwXSkVQ%3D%3D">LaTeX Docker Container for forms</a>, we illustrated how to generate PDFs from templates created with Indesign and dynamic JSON/XML data, using a LaTeX Docker container.</p><p>Now, regarding the positioning of the various text blocks relative to the template, we have several options:</p><ul><li>Proceed by trial and error.</li><li>Use the position information directly from Indesign.</li><li>Develop a prototype Indesign plug-in to display the position of the selected block and preformat the text blocks.</li></ul><h3>Setting up the LaTeX file</h3><p>In the past, with other libraries, the reference zero did not always correspond to that of the template, and it was often necessary to calculate offsets to align the inserted text with the ‘static’ text present in the templates.</p><p>With LaTeX, however, we can use the values retrieved from Indesign to position the blocks directly.</p><p>Currently, the data to be inserted does not exceed a single line. For this reason, for now, we have only used the ‘textblock*’ option, which allows absolute positioning.</p><p>As a reference, here is a part of a file used for testing.</p><p>n.b.: \raggedright allows left-aligning the text, which otherwise, by default, maintains a ‘padding’ from the horizontal edge.</p><h3>Positioning by trial and error</h3><p>This is certainly the simplest method, but also the longest and most tedious, especially when the number of text blocks starts to grow.</p><h3>Using position information directly from Indesign</h3><p>By selecting the text block in Indesign and accessing Window -&gt; Info, you can view the coordinates of the selected block.</p><figure><img alt="indesign info" src="https://cdn-images-1.medium.com/max/266/1*KPdceSZWA_a6mzRPYIMN5Q.png" /></figure><h3>Using a prototype Indesign plug-in</h3><p>The first prototype created is a plug-in for Indesign that allows you to view the position of the selected block and preformat the text blocks.</p><figure><img alt="UXP position pannel" src="https://cdn-images-1.medium.com/max/393/1*LFh2KO3sLLhNjAj3ho1UwA.png" /></figure><p>Unfortunately, this method does not offer a great advantage over the previous one, but it provides a starting point for analyzing the page.</p><h3>Our solution</h3><p>Currently, we are still conducting tests and trials, but the basic idea is to insert ‘dynamic’ text blocks into the template with a different color from the static ones and, instead of the text, directly insert the XSLT block that will then be used to generate the final XML, LaTeX, and PDF.</p><figure><img alt="xslt tag" src="https://cdn-images-1.medium.com/max/636/1*mae3TCB8LlvjllweHZLUIQ.png" /></figure><p>Each block can be identified with a unique ID through the XML tags managed directly by Indesign.</p><p>Our plug-in returns, for each tag on the page, preformatted blocks for LaTeX, as shown in the following image.</p><figure><img alt="indesign latex conf" src="https://cdn-images-1.medium.com/max/566/1*JC6F24RfQbunICqvMP6OKA.png" /></figure><p>These blocks can be copied and pasted directly into the LaTeX file to generate the final PDF.</p><p>After compilation, the resulting PDF will look like this.</p><figure><img alt="pdf result" src="https://cdn-images-1.medium.com/max/130/1*AUKxd2oY2sMplbGcmU3uZw.png" /></figure><p>At this point, we will only need to align the blocks that are not perfectly consistent with the template.</p><h3>Conclusions</h3><p>The proposed solution is still in the testing and development phase, but it allows us to have a starting point for generating PDFs from Indesign templates with dynamic data.</p><p>We are not experts enough to publish the plug-in, but we hope it can be a cue or a useful idea for someone.</p><h3>In progress</h3><p>At the moment, we are already testing a sort of cluster with microservices, all in remote Docker containers, for now on HTTP:</p><ul><li>PDF generation request to the back-end, for example, for a customer order.</li><li>Data retrieval from the database.</li><li>Generation with XSLT transformation into LaTeX.</li><li>PDF generation from LaTeX generated with dynamic data.</li><li>Sending the PDF to the client.</li></ul><p>Thank you for your attention and good work!</p><p>Thanks to Gemini for assistance in the final drafting of this article. and Copilot for English translation.</p><h4>Thank you for taking the time to read this</h4><p>… and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/245/1*i6pS5eeLLFnSTVTWhjI9ZA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=852764c93689" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LaTeX Docker Container for Forms [Work in Progress]]]></title>
            <link>https://medium.com/@exclusivetech.ch/latex-docker-container-for-forms-work-in-progress-2846ad8063ce?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2846ad8063ce</guid>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Tue, 18 Mar 2025 15:14:34 GMT</pubDate>
            <atom:updated>2025-04-11T20:39:27.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sB2vPwkMLTvyoFzJ3WYQTw.png" /><figcaption>sunrise on moon desert (with wind)</figcaption></figure><p><strong><em>Translated from Italian from </em></strong><a href="https://www.linkedin.com/pulse/latex-docker-container-per-modulistica-drservice-it-naqtf/?trackingId=%2Bs9mZvi53LkCMM7Tih26Xw%3D%3D"><strong><em>LinkedIn</em></strong></a></p><p>Notes for a web service based on Docker containers, designed to generate PDF files using LaTeX. The goal is to compile custom forms, such as offers and quotes, from predefined templates.</p><h4>Premise</h4><p>The initial need was to produce PDF files with a uniform graphic design, avoiding the typical appearance of preformatted spreadsheets. To this end, PDF templates were created in Indesign, containing logos and fixed graphic blocks, to be subsequently combined with data in JSON/XML format from SQL databases.</p><p>The transformation of data into XML, interpretable by the server (initially in PHP, now in Go), was done via XSLT. The server used libraries for PDF management to compile the preloaded static templates.</p><p>The system, in use for years, has some limitations in implementing new features. Hence the need to integrate it with a more versatile and reliable solution.</p><h4><strong>A solution: integration with LaTeX</strong></h4><p>Among the various options, the integration of LaTeX for PDF generation was evaluated. The project, started over a year ago, was recently resumed after a period of inactivity.</p><p>Currently in the testing phase, the LaTeX-based system operates in parallel with the production one. The only server-side change was the introduction of an external service for PDF generation.</p><h4><strong>System architecture</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*_QRibYcjbyujQgEXJpITNA.png" /><figcaption>pdf request flow</figcaption></figure><p>Each component is an independent unit, except for PDF templates. The “Saxon” block manages the compilation and association of XSLT stylesheets to the forms.</p><p><strong>Note:</strong> All components operate on an internal network and are not accessible from the outside.</p><h4><strong>Docker Containers</strong></h4><p>For the testing phase, a Debian/Node image was used, on which LaTeX and a simple Express server were installed as an endpoint.</p><p>Below, the key points will be listed, pending the ability to share specific code blocks, free of comments and sensitive data.</p><h4>dockerfile</h4><pre>FROM node:23-bookworm AS build<br><br># necessary packages for LaTeX<br>RUN apt-get update &amp;&amp; apt-get install -y \<br>    texlive-latex-base \<br>    texlive-latex-recommended \<br>    texlive-latex-extra \<br>    texlive-fonts-recommended \<br>    texlive-fonts-extra \<br>    &amp;&amp; apt-get clean \<br>    &amp;&amp; rm -rf /var/lib/apt/lists/*<br><br>...<br><br>VOLUME /home/node/app/assets/bg-templates<br><br>...<br><br># node express src files if dockefile in same app folder<br>COPY ./package*.json ./<br>COPY ./tsconfig.json ./<br>COPY ./src/ ./src<br><br>...<br><br>RUN npm install<br>RUN npx tsc </pre><h4>docker-compose</h4><pre>...<br><br>volumes:<br>      - your-path/bg-templates:/home/node/app/assets/bg-templates<br>...<br> command: &quot;node dist/index.js&quot;</pre><p>in express creo un endpoint ‘parse’</p><pre>app.post(&quot;/parse&quot;, (req, res) =&gt; {<br>   // base64<br>    const body = atob(req.body.latex);<br><br>  texParse(body, (pdflatex: string | ExecException) =&gt; {<br>    // res.render(&#39;index&#39;, { latex: body.latex, pdfresp: pdflatex });<br>    res.send(pdflatex);<br>  });<br>});<br><br>...<br><br>function texParse(<br>  latex: string,<br>  $callback: (pdflatex: string | ExecException) =&gt; void<br>) {<br>  const texPath = &quot;/usr/bin&quot;;<br>  const vol = require(&quot;fs&quot;);<br>  const path = `/home/node/app/assets/latex2pdf`;<br>  const name = &quot;latex2pdf&quot;;<br>  const texFilePath = `${path}/${name}.tex`;<br>  const pdfFilePath = `${path}/${name}.pdf`;<br>  const cmd = `${texPath}/pdflatex -interaction=nonstopmode -output-directory=${path} ${texFilePath}`;<br><br>  vol.writeFileSync(texFilePath, latex);<br><br>  const exec = require(&quot;child_process&quot;).exec;<br>  exec(<br>    cmd,<br>    { stdio: &quot;pipe&quot;, env: { ...process.env, PATH: &quot;&quot; } },<br>    (error: any, stdout: string) =&gt; {<br>      let ret: string | ExecException = &quot;&quot;;<br>      if (stdout) {<br>        try {<br>          const pdf = vol.readFileSync(pdfFilePath);<br>          ret = pdf.toString(&quot;base64&quot;);<br>        } catch (readError) {<br>          ret = (readError as Error).message;<br>        }<br>      }<br>      if (error) {<br>        ret = error.message;<br>      }<br>      $callback(ret);<br>    }<br>  );<br>}</pre><h4>Thank you for taking the time to read this</h4><p>… and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/245/1*i6pS5eeLLFnSTVTWhjI9ZA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2846ad8063ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up an Etcd-Patroni-PostgreSQL and HAProxy cluster]]></title>
            <link>https://medium.com/@exclusivetech.ch/setting-up-an-etcd-patroni-postgresql-and-haproxy-cluster-0ed2d55160ec?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ed2d55160ec</guid>
            <category><![CDATA[etcd]]></category>
            <category><![CDATA[haproxy]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[postgresql-database]]></category>
            <category><![CDATA[patroni]]></category>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Mon, 15 Jul 2024 17:49:35 GMT</pubDate>
            <atom:updated>2025-04-11T20:32:29.156Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>( </strong>original Italian version on<a href="https://www.linkedin.com/pulse/trattamento-di-un-cluster-etcd-patroni-postgresql-e-haproxy-5znaf"><strong> linkedin</strong></a><strong> </strong>automatic translation into English by google translate then corrected and played by gemini<strong>)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1u136Y96PDqhb8ICWdAMkQ.jpeg" /><figcaption>Adobe Firefly: ‘fantastico panorama intergalattico con interconnessione tra pianeti e stelle’</figcaption></figure><p>This document provides configuration files for creating a 2-node PostgreSQL cluster with Patroni and Etcd, along with HAProxy for load balancing.</p><p>It utilizes dedicated VMware virtual machines running Photon OS with Docker/Docker-compose installed.</p><p>The installation process is not included in this guide.</p><h3>…and keep in mind that…</h3><p>While not automated for production use, the configuration is designed for a separate subnet with no external access, so security is not a major concern in this context.</p><p>Although intended for development, the configuration aims to be production-ready.</p><p>It might not be optimal, but serves as a functional starting point.</p><h3>Configuration Legend</h3><ul><li>${DB_NAME}: Database name</li><li>${DB_USER_NAME}: Username for the database user</li><li>${DB_PASSWORD}: Password for the database user</li><li>${IP_NODO_X}: IP address of node &quot;X&quot;</li><li>${IP_NODO_HA}: IP address of the HAProxy node</li></ul><p>There are currently no automated installation scripts, so the steps are manual.</p><h3>PostgreSQL Patron Etcd Nodes</h3><p>This configuration needs to be repeated for each node “X” in the cluster.</p><h4>. Patroni configuration patroni.yml</h4><pre>scope: miopg16cluster<br>namespace: /mio_pg16_cluster/<br>name: pgsql16clu01<br><br>log:<br>  format: &#39;%(asctime)s %(levelname)s: %(message)s&#39;<br>  # ERROR INFO DEBUG<br>  level: ERROR<br>  max_queue_size: 1000<br>  traceback_level: ERROR<br>  type: plain<br><br>restapi:<br>  listen: 0.0.0.0:8008<br>  connect_address: ${IP_NODO_1}:8008<br><br>etcd3:<br>  hosts: <br>    - ${IP_NODO_1}:2379<br>    - ${IP_NODO_2}:2379<br><br>bootstrap:<br>  dcs:<br>    ttl: 30<br>    loop_wait: 10<br>    retry_timeout: 10<br>    maximum_lag_on_failover: 1048576<br>  postgresql:<br>      use_pg_rewind: true<br>      use_slots: true<br>      parameters:<br>        password_encryption: scram-sha-256<br>        wal_level: hot_standby<br>        hot_standby: &quot;on&quot;<br>        max_connections: 100<br>        max_worker_processes: 8<br>        wal_keep_segments: 8<br>        max_wal_senders: 10<br>        max_replication_slots: 10<br>        max_prepared_transactions: 0<br>        max_locks_per_transaction: 64<br>        wal_log_hints: &quot;on&quot;<br>        track_commit_timestamp: &quot;off&quot;<br>        archive_mode: &quot;on&quot;<br>        archive_timeout: 1800s<br>        archive_command: mkdir -p ../wal_archive &amp;&amp; test ! -f ../wal_archive/%f &amp;&amp; cp %p ../wal_archive/%f<br>      recovery_conf:<br>        restore_command: cp ../wal_archive/%f %p<br>  initdb:<br>  - encoding: UTF8<br>  - data-checksums<br>  pg_hba:<br>  - host replication replicator 127.0.0.1/32 scram-sha-256<br>  - host replication replicator ${IP_NODO_1}/32 scram-sha-256<br>  - host replication replicator ${IP_NODO_2}/32 scram-sha-256<br>  # poi replicator<br>  - host replication ${NOME_DB_USER} ${IP_NODO_1}/32 trust<br>  - host replication ${NOME_DB_USER} ${IP_NODO_2}/32 trust<br>  - host all all 0.0.0.0/0 scram-sha-256<br>  users:<br>    admin:<br>      password: admin<br>      options:<br>        - createrole<br>        - createdb<br><br>postgresql:<br>  listen: 0.0.0.0:5432<br>  connect_address: ${IP_NODO_1}:5432<br>  data_dir: /var/lib/postgresql/data<br>  bin_dir: /usr/local/bin<br>  pgpass: /tmp/pgpass<br>  authentication:<br>    replication:<br>      username: ${NOME_DB_USER}<br>      password: ${DB_PASSWORD}<br>    superuser:<br>      username: ${NOME_DB_USER}<br>      password: ${DB_PASSWORD}<br>  tags:<br>    nofailover: false<br>    noloadbalance: false<br>    clonefrom: false<br>    nosync: false<br><br>watchdog:<br>  mode: &#39;off&#39;<br>  device: /dev/watchdog<br>  safety_margin: 5</pre><h4><strong>. Patroni image </strong><strong>patroni.dockerfile</strong></h4><p>This section describes how to build a custom Docker image for Patroni to avoid conflicts with system-wide Python libraries like:</p><pre>× This environment is externally managed                                                                   <br>1.294 ╰─&gt;                                                                                                        <br>1.294     The system-wide python installation should be maintained using the system<br>1.294     package manager (apk) only.</pre><pre>##<br>## STEP 1 - BUILD<br>##<br><br>FROM postgres:16-alpine as postgres-patroni<br><br># Install Patroni dependencies<br>RUN apk add --no-cache build-base linux-headers python3-dev py3-pip py3-virtualenv \<br>    &amp;&amp; python3 -m venv /venv &amp;&amp; mkdir /venv/etc<br><br># Create a virtual environment<br># RUN python3 -m venv /venv &amp;&amp; mkdir /venv/etc<br><br># Install Patroni<br># prima mi metto nel punto<br>WORKDIR /venv<br># RUN /venv/bin/pip install patroni[etcd]<br># diventa<br>RUN ./bin/pip install psycopg2 &amp;&amp; ./bin/pip install patroni[etcd]<br><br># Copy the Patroni configuration file into the container<br>COPY patroni.yml /venv/etc/patroni.yml<br><br># Set the working directory to the PostgreSQL home directory<br>WORKDIR /var/lib/postgresql<br><br># blocco avvio postgresql<br># Copy your custom entrypoint script into the container<br>COPY pgsql16clu01-entrypoint.sh /usr/local/bin/pgsql16clu01-entrypoint.sh<br><br># Make sure the script is executable<br>RUN chmod +x /usr/local/bin/pgsql16clu01-entrypoint.sh<br><br># Set your custom entrypoint script<br>ENTRYPOINT [&quot;pgsql16clu01-entrypoint.sh&quot;]<br><br># Expose ports for PostgreSQL and Patroni&#39;s REST API<br>EXPOSE 5432 8008<br><br># Start Patroni su entry point</pre><p><strong><em>Explanation</em>:</strong></p><ul><li><strong>Base Image:</strong> Starts with the postgres:16-alpine image.</li><li><strong>Install Dependencies:</strong> Installs necessary build tools (build-base, linux-headers), Python development libraries (python3-dev, py3-pip, py3-virtualenv) using apk.</li><li><strong>Create Virtual Environment:</strong></li><li>Creates a virtual environment named /venv and a directory /venv/etc within the container.</li><li><strong>Install Patroni:</strong></li><li>Switches to the virtual environment directory (/venv).</li><li>Installs psycopg2 and patroni[etcd] libraries using pip.</li><li><strong>Copy Patroni Configuration:</strong> Copies the patroni.yml configuration file into /venv/etc/patroni.yml within the container.</li><li><strong>Set Working Directory:</strong> Sets the working directory to /var/lib/postgresql, the standard location for PostgreSQL data.</li><li><strong>Custom Entrypoint Script:</strong></li><li>Copies the pgsql16clu01-entrypoint.sh script into the container at /usr/local/bin/pgsql16clu01-entrypoint.sh.</li><li>Makes the script executable using chmod +x.</li><li>Sets the custom script as the container’s entrypoint using ENTRYPOINT. This script likely performs additional actions during container startup.</li><li><strong>Expose Ports:</strong> Exposes ports 5432 for PostgreSQL and 8008 for Patroni&#39;s REST API.</li><li><strong>Start Patroni (Likely within the custom entrypoint script):</strong> Starts the Patroni process.</li></ul><h4><strong>patroni-postgresql entrypoint </strong><strong>pgsql16clu01-entrypoint.sh</strong></h4><p>This script defines a custom entrypoint for the container, overriding the default behavior of the postgres:16-alpineimage.</p><pre>#!/bin/bash<br><br># Example custom entrypoint script.<br># Here you can include any setup tasks.<br># Note: This script does not start PostgreSQL.<br><br># Example: echo &quot;PostgreSQL will not start automatically&quot;<br>echo &quot;PostgreSQL wait patroni to start&quot;<br># To start PostgreSQL manually, you would typically use:<br># exec postgres<br><br># If you decide not to start PostgreSQL, you can keep the container running with:<br># exec tail -f /dev/null<br>#<br># Initialize PostgreSQL data directory (if not already initialized)<br># questo se non esiste e aggiungo anche mia parte<br>if [ ! -d &quot;/var/lib/postgresql/data&quot; ]; then<br>    mkdir -p /var/lib/postgresql/data<br>    chown postgres:postgres /var/lib/postgresql/data<br>    su-exec postgres initdb -D /var/lib/postgresql/data<br>    set -e<br><br>su-exec postgres psql -v ON_ERROR_STOP=1 --username &quot;$POSTGRES_USER&quot; --dbname &quot;$POSTGRES_DB&quot; &lt;&lt;-EOSQL<br>    CREATE DATABASE ${NOME_DB};<br>    GRANT ALL PRIVILEGES ON DATABASE ${NOME_DB} TO ${NOME_DB_USER};<br>EOSQL<br>fi<br><br># Start Patroni<br>exec su-exec postgres /venv/bin/patroni /venv/etc/patroni.yml</pre><p><strong><em>Explanation:</em></strong></p><ul><li><strong>No Automatic PostgreSQL Start:</strong> This script intentionally avoids starting PostgreSQL automatically. The script waits for Patroni to initiate the process.</li><li><strong>Customization Opportunities:</strong> The comment section provides examples of potential modifications, such as echoing a message or using exec tail -f /dev/null to keep the container running.</li><li><strong>Initializing PostgreSQL Data Directory (Optional):</strong></li><li>Checks if the /var/lib/postgresql/data directory exists.</li><li>If not, creates the directory, sets ownership to postgres:postgres, initializes the database using su-exec postgres initdb, and sets error handling to strict mode (set -e).</li><li><strong>Creating Database and User (Optional):</strong></li><li>Uses su-exec postgres psql to connect to the database as the postgres user.</li><li>Checks the environment variables POSTGRES_USER and POSTGRES_DB (likely defined elsewhere).</li><li>Conditionally creates the database specified by ${DB_NAME} and grants all privileges to the user ${DB_USER_NAME} within that database.</li><li><strong>Starting Patroni:</strong> Uses su-exec postgres to run the patroni command with the configuration file path (/venv/etc/patroni.yml) inside the virtual environment.</li></ul><h4><strong>Docker-compose `docker-compose.yml`</strong></h4><pre>version: &#39;3.9&#39;<br><br>services:<br><br>  etcdnode01:<br>    image: quay.io/coreos/etcd:v3.4.33<br>    container_name: etcdnode01<br>    restart: unless-stopped<br>    logging:<br>      options:<br>        max-size: &quot;1m&quot;<br>        max-file: &quot;5&quot;<br>    volumes:<br>      - etcdnode_data:/etcd-data<br>    environment:<br>      ETCD_DATA_DIR: /etcd-data<br>      ETCD_NAME: etcdnode01<br>      ETCD_INITIAL_ADVERTISE_PEER_URLS: http://${IP_NODO_1}:2380<br>      ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380<br>      ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379<br>      ETCD_ADVERTISE_CLIENT_URLS: http://${IP_NODO_1}:2379<br>      # ETCD_INITIAL_CLUSTER: etcdnode01=http://etcdnode01:2380,etcdnode02=http://${IP_NODO_2}:2380<br>      ETCD_INITIAL_CLUSTER: etcdnodeha01=http://${IP_NODO_HA}:2380,etcdnode01=http://${IP_NODO_1}:2380,etcdnode02=http://${IP_NODO_2}:2380<br>      ETCD_INITIAL_CLUSTER_TOKEN: etcd-postgresl-cluster<br>      ETCD_INITIAL_CLUSTER_STATE: new<br>    ports:<br>      - &quot;2379:2379&quot;<br>      - &quot;2380:2380&quot;<br>      # - 4001:4001<br>    network_mode: &quot;host&quot;<br><br><br>  pgsql16clu01:<br>    # image: postgres:16-alpine NO<br>    container_name: pgsql16clu01<br>    # depends_on:<br>    #  - etcdnode01<br>    build:<br>      dockerfile: ./patroni.dockerfile<br>      context: .<br>      target: postgres-patroni<br>    restart: unless-stopped<br>    logging:<br>      options:<br>        max-size: &quot;1m&quot;<br>        max-file: &quot;5&quot;<br>    environment:<br>      POSTGRES_USER: ${NOME_DB_USER}<br>      POSTGRES_PASSWORD: ${DB_PASSWORD}<br>    volumes:<br>      - postgres_data:/var/lib/postgresql/data<br>      # COPY patroni.yml /etc/patroni.yml<br>      - ./patroni.yml:/venv/etc/patroni.yml<br>    ports:<br>      - &quot;5432:5432&quot;<br>      - &quot;8008:8008&quot;<br>    network_mode: host<br>    depends_on:<br>      - etcdnode01<br><br>  <br>volumes:<br>  postgres_data:<br>  etcdnode_data:</pre><p><strong><em>Explanation</em> of the </strong><strong>docker-compose.yml section:</strong></p><p>This section defines the services for running Etcd and Patroni/PostgreSQL nodes using Docker Compose.</p><ul><li><strong>version:</strong> Specifies the Docker Compose version used (3.9 in this case).</li><li><strong>services:</strong> Defines the individual services:</li><li><strong>etcdnode01:</strong> Defines an Etcd container named etcdnode01 using the quay.io/coreos/etcd:v3.4.33image.</li><li><strong>pgsql16clu01:</strong> Defines a PostgreSQL container with Patroni using a custom Dockerfile (./patroni.dockerfile) built within the context of the current directory. The target image is named postgres-patroni. The container depends on etcdnode01.</li><li><strong>volumes:</strong> Defines persistent storage volumes:</li><li><strong>postgres_data:</strong> Used for storing PostgreSQL data.</li><li><strong>etcdnode_data:</strong> Used for storing Etcd data.</li><li><strong>networks:</strong> Both services (etcdnode01 and pgsql16clu01) use host network mode, which assigns the host&#39;s IP address to the containers. This might not be ideal for production environments due to security considerations.</li></ul><h3><strong>haproxy.cfg</strong></h3><p>This section defines the configuration for HAProxy, which acts as a load balancer for your PostgreSQL cluster.</p><pre>global<br>    log stdout format raw local0<br>    maxconn 100<br><br>defaults<br>    log     global<br>    mode    tcp<br>    retries 2<br>    option  tcplog<br>    timeout connect 5000ms<br>    timeout client  50000ms<br>    timeout server  50000ms<br><br># Frontend for write requests on the default PostgreSQL port<br>frontend write_frontend<br>    bind *:5432<br>    default_backend postgresql_write_backend<br><br># Backend for write requests, pointing to the leader<br>backend postgresql_write_backend<br>    option httpchk GET /healthz/ready HTTP/1.1<br>    http-check expect status 200<br>    default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions<br>    balance first<br>    server pgsql16clu01 ${IP_NODO_1}:5432 maxconn 100 check port 8008<br>    # no altrimenti li prende tutti e due<br>    # server pgsql16clu02 ${IP_NODO_2}:5432 maxconn 100 check port 8008<br><br># Frontend for read requests on port 5434<br>frontend read_frontend<br>    bind *:5434<br>    default_backend postgresql_read_backend<br><br># Backend for read requests, including all nodes<br>backend postgresql_read_backend<br>    option httpchk GET /healthz/ready HTTP/1.1<br>    http-check expect status 200<br>    # altrimenti marca replica down<br>    # default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions<br>    balance roundrobin<br>    server pgsql16clu01 ${IP_NODO_1}:5432 maxconn 100 check port 8008<br>    server pgsql16clu02 ${IP_NODO_2}:5432 maxconn 100 check port 8008<br><br># HAProxy stats<br>listen stats<br>    bind *:7000<br>    mode http<br>    stats enable<br>    stats uri /<br>    stats refresh 10s</pre><p><strong>Explanation:</strong></p><ul><li><strong>Global Settings:</strong></li><li>Configures logging and connection limits for HAProxy.</li><li><strong>Defaults:</strong></li><li>Sets default settings for all backends and servers.</li><li><strong>Write Requests Frontend:</strong> (“write_frontend”)</li><li>Binds to port 5432 for incoming write requests.</li><li>Points all connections to the postgresql_write_backend.</li><li><strong>Write Requests Backend:</strong> (“postgresql_write_backend”)</li><li>Performs health checks (/healthz/ready) on port 8008 to ensure the backend is healthy (presumably this port is exposed by Patroni).</li><li>Uses the first balancing algorithm, which sends all connections to the first available healthy server.</li><li>Points to the leader PostgreSQL server on pgsql16clu01:${IP_NODO_1}:5432.</li><li>Disables using the secondary server (pgsql16clu02) to avoid accidentally directing writes there.</li><li><strong>Read Requests Frontend:</strong> (“read_frontend”)</li><li>Binds to port 5434 for incoming read requests.</li><li>Points all connections to the postgresql_read_backend.</li><li><strong>Read Requests Backend:</strong> (“postgresql_read_backend”)</li><li>Performs health checks (/healthz/ready) on port 8008 to ensure backend health.</li><li>Uses round robin balancing, distributing read requests across available servers.</li><li>Includes both pgsql16clu01 and pgsql16clu02 for read traffic.</li><li><strong>HAProxy Stats: </strong>Enables an HTTP interface on port 7000 for monitoring HAProxy statistics.</li></ul><h4><strong>. Docker-compose.yml</strong></h4><p>This section defines the services for running the additional Etcd node (for HA) and the HAProxy container using Docker Compose.</p><pre>version: &#39;3.9&#39;<br><br>services:<br><br>  etcdnodeha01:<br>    image: quay.io/coreos/etcd:v3.4.33<br>    container_name: etcdnodeha01<br>    restart: unless-stopped<br>    logging:<br>      options:<br>        max-size: &quot;1m&quot;<br>        max-file: &quot;5&quot;<br>    volumes:<br>      - etcdnode_data:/etcd-data<br>    environment:<br>      ETCD_DATA_DIR: /etcd-data<br>      ETCD_NAME: etcdnodeha01<br>      ETCD_INITIAL_ADVERTISE_PEER_URLS: http://${IP_NODO_HA}:2380<br>      ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380<br>      ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379<br>      ETCD_ADVERTISE_CLIENT_URLS: http://${IP_NODO_HA}:2379<br>      # ETCD_INITIAL_CLUSTER: etcdnode01=http://etcdnode01:2380,etcdnode02=http://${IP_NODO_2}:2380<br>      ETCD_INITIAL_CLUSTER: etcdnodeha01=http://${IP_NODO_HA}:2380,etcdnode01=http://${IP_NODO_1}:2380,etcdnode02=http://${IP_NODO_2}:2380<br>      ETCD_INITIAL_CLUSTER_TOKEN: etcd-postgresl-cluster<br>      # if this add later existing<br>      ETCD_INITIAL_CLUSTER_STATE: existing<br>    ports:<br>      - &quot;2379:2379&quot;<br>      - &quot;2380:2380&quot;<br>      # - 4001:4001<br>    network_mode: &quot;host&quot;<br><br>  haproxy01:<br>    image: haproxy:latest<br>    container_name: haproxy01<br>    restart: unless-stopped<br>    logging:<br>      options:<br>        max-size: &quot;1m&quot;<br>        max-file: &quot;5&quot;<br>    volumes:<br>      - ./haproxy01.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro<br>    ports:<br>      - &quot;5000:5000&quot; # Expose HAProxy on port 5000<br>    network_mode: &quot;host&quot;<br><br>volumes:<br>  etcdnode_data:</pre><p><strong><em>Explanation</em>:</strong></p><ul><li><strong>etcdnodeha01:</strong> Defines an additional Etcd container named etcdnodeha01 configured as part of the HA cluster.</li><li><strong>haproxy01:</strong> Defines an HAProxy container named haproxy01 with the configuration file mounted from the current directory (./haproxy01.cfg).</li><li>Exposes the HAProxy service on port 5000 of the host machine.</li></ul><h3>Summary of Testing and Configuration Tips</h3><p>This section provides valuable information for starting and managing your Etcd cluster and PostgreSQL database with Patroni.</p><p><strong>Key Points:</strong></p><ul><li><strong>Etcd Cluster Startup Order:</strong> Starting and stopping Etcd containers can be tricky. Stopping and restarting an Etcd container within a cluster can lead to issues if it loses its cluster ID.</li><li><strong>Verifying Etcd Status:</strong> The provided commands using docker exec and etcdctl allow you to check the health of individual Etcd nodes and the overall cluster state.</li><li><strong>Listing Etcd Members:</strong> This command displays information about each member in the Etcd cluster, including their ID, status, name, and connection details.</li><li><strong>Dumping an Existing Database:</strong> The script provides a method to dump an existing database with exclusions. This can be useful for testing purposes.</li><li><strong>Excluding Tables from Backup:</strong> The script utilizes a file exclude_dman_tables.txt to specify tables to exclude from the database backup.</li><li><strong>Patroni Considerations:</strong> While not explicitly mentioned, this section likely assumes that Patroni is managing the PostgreSQL cluster and interacting with Etcd for leader election.</li></ul><p><strong>Additional Notes:</strong></p><ul><li>The script seems to be tailored for a specific scenario where tables with final numbers (e.g., dman.table123) are excluded from the backup.</li><li>Consider reviewing security implications before using the docker exec command for production environments.</li></ul><h4>Thank you for taking the time to read this</h4><p>… and</p><figure><a href="https://buy.stripe.com/fZe28b6hC7d13cs5kk"><img alt="coffee for me — thanks in advance for your appreciation" src="https://cdn-images-1.medium.com/max/245/1*i6pS5eeLLFnSTVTWhjI9ZA.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ed2d55160ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why is 17 my number?]]></title>
            <link>https://medium.com/@exclusivetech.ch/why-is-17-my-number-05127cf0a381?source=rss-be2e669b1a4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/05127cf0a381</guid>
            <dc:creator><![CDATA[Exclusive Technologies]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 14:57:13 GMT</pubDate>
            <atom:updated>2023-12-11T14:57:13.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gH-KFWnaJt9Os7LGHgeuzQ.png" /><figcaption>my photo background</figcaption></figure><p><a href="https://www.linkedin.com/pulse/perch%2525C3%2525A8-17-%2525C3%2525A8-il-mio-numero-drservice-it-lejtf%3FtrackingId=65WXAw8gMKrwuwrWAFTaqQ%253D%253D/?trackingId=65WXAw8gMKrwuwrWAFTaqQ%3D%3D">original text</a> written in Italian and, since I don’t trust my English, I preferred to rely on Google ;)… I apologize for the inaccuracies.</p><p>Today I was thinking of updating, transferring, a small angular app. The first idea was simply to recreate the new starting point and copy/import the various blocks from the existing one… why not try the new version 17 and update and improve the new app and the opportunity to ‘ browse ‘, (.. . and review the documentation, ed.), the new beta docs version of <a href="https://angular.dev/">Angular</a> , described in detail on <a href="https://blog.angular.io/announcing-angular-dev-1e1205fa3039">medium</a> which, personally, I find captivating.</p><h3>premise</h3><p>These are notes of how I dealt with the situation, certainly given my skills, it is not the best system and, perhaps, it is even wrong… so be careful.</p><h3>stand-alone installation</h3><p>I always prefer to avoid, unless forced, installing globally.</p><p>So, starting from the assumption that ‘npm/nvm’ is already installed, as in my case, I create a folder which, in the end, will contain the folder of the actual app.</p><pre>./dev-folder <br>   | - /app-folder <br>... if needed <br>   | - /app2-folder <br>   | - /app3-folder</pre><p>As logic, in dev-folder:</p><ul><li>I install angular/cli, updated to the version I need, in this case 17</li><li>I generate the new app(s).</li><li>I remove folders generated by ‘cli’</li></ul><p>at this point app-folder has its own independent angular version that can be updated, modified, duplicated etc.</p><pre>$ cd dev-folder<br>// !! without -g<br>$ npm install @angular/cli<br>// probably $PATH is not set<br>$ ./node_modules/.bin/ng new app-folder<br>// and remove first installation<br>$ rm -rf node_modules/<br>$ rm package-lock.json package-lock.json<br>// cd child dir<br>$ cd app-folder<br>// git setup<br>// Remove the history from if necessary<br>$ rm -rf .git<br>// recreate the repos from the current content only<br>$ git init<br>$ git add .<br>// set nome / mail<br>$ git config user.name &quot;yourname&quot;<br>$ git config user.email &quot;your@mail&quot;<br>// start git master =&gt; now main<br>$ git commit -m &quot;app-folder main&quot;<br>// test installation<br>$ ng serve</pre><pre>// !!! depending on your installation check $PATH if &#39;ng&#39; gives an error</pre><p>and if everything is ok -&gt; <a href="http://localhost:4200/">http://localhost:4200</a> …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*eASHja6HuJD7hQ9_" /></figure><p>…splah page is also new</p><h3>… some changes or optional additions</h3><p>Out of habit I change the prefix to angular.json ,</p><pre>&quot;prefix&quot;: &quot;mypref&quot;</pre><p>accordingly in index.html</p><pre>&#39;app-root&#39; becoming &#39;mypref-root&#39;</pre><p>if necessary always change default port in angular.json [4200]</p><pre>&quot;serve&quot;: {<br>    &quot;builder&quot;: &quot;@angular-devkit/build-angular:dev-server&quot;,<br>    &quot;options&quot;: {<br>    &quot;port&quot;: my new port<br> },</pre><p>e genre environment e ESLint</p><pre>of generate environments <br>of add @angular-eslint/schematics</pre><blockquote><em>if you change prefix update ‘.eslintrc.json’</em></blockquote><pre>&quot;@angular-eslint/component-selector&quot; -&gt; &quot;prefix&quot;: &quot;mypref&quot;</pre><p>if everything ok</p><pre>npm run lint</pre><p>It may be useful to install</p><pre>-- per app vera e propria<br>ng add @angular/pwa    // se ssr<br>-- per gestione stati<br>npm install @ngxs/store --save<br>npm install @ngxs/storage-plugin --save<br>@rx-angular/state</pre><pre>-- per gui<br>npm install bootstrap<br>npm install bootstrap-icons</pre><pre>npm install @fortawesome/angular-fontawesome<br>npm install @fortawesome/fontawesome-svg-core<br>npm install @fortawesome/free-brands-svg-icons<br>npm install @fortawesome/free-regular-svg-icons<br>npm install @fortawesome/free-solid-svg-icons</pre><p>per bootstrap</p><p>in angular.json</p><pre>&quot;styles&quot;: [<br>     &quot;node_modules/bootstrap-icons/font/bootstrap-icons.scss&quot;,<br>     &quot;src/styles.scss&quot;<br>],</pre><p>in styles.scss at the end add</p><pre>@import &quot;../node_modules/bootstrap/scss/bootstrap.scss&quot;;</pre><p>and in index.html, lang as needed, for now it</p><pre>&lt;html lang=&quot;it&quot; data-bs-theme=&quot;dark&quot;&gt;</pre><p>and in app.component.html, ex: next to {{ title }}</p><pre>&lt;i class=&quot;bi-alarm&quot;&gt;&lt;/i&gt;</pre><p>if everything ok…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*PJMzAZDtHZ4henVs" /></figure><p>bootstrap dark theme e icona alarm</p><p>for fontawesome, however, I imported the module into app.module</p><pre>// old module<br>import { NgModule } from &#39;@angular/core&#39;;</pre><pre>import { FontAwesomeModule, FaIconLibrary } from &#39;@fortawesome/angular-fontawesome&#39;;<br>import * as faR from &#39;@fortawesome/free-regular-svg-icons&#39;;<br>import * as faS from &#39;@fortawesome/free-solid-svg-icons&#39;;</pre><pre>@NgModule({<br>    imports: [<br>        FontAwesomeModule<br>    ],<br>    declarations: [],<br>    exports: [<br>        FontAwesomeModule<br>    ]<br>})<br>export class ExtFontawesomeModule {<br>    constructor(library: FaIconLibrary) {<br>        // import tutte le icone<br>        library.addIconPacks(faS.fas, faR.far);<br>        /*<br>        // ok questa funziona x singole icone<br>        library.addIcons(<br>            faR.faStar,</pre><pre>            faS.faAt,<br>            faS.faCalendarDay,<br>            ... etc.<br>        );<br>        */<br>    }<br>}</pre><p>for now only as texts in app.component.ts import</p><pre>import { FontAwesomeModule, FaIconLibrary } from &#39;@fortawesome/angular-fontawesome&#39;;<br>import * as faR from &#39;@fortawesome/free-regular-svg-icons&#39;;<br>import * as faS from &#39;@fortawesome/free-solid-svg-icons&#39;;</pre><p>and I add</p><pre>standalone: true,<br>  imports: [<br>    CommonModule,<br>    RouterOutlet,<br>    FontAwesomeModule,<br>  ],</pre><pre>...</pre><pre>export class AppComponent {<br>  title = &#39;your-title&#39;;<br>  constructor(library: FaIconLibrary) {<br>    library.addIconPacks(faR.far, faS.fas);<br>  }</pre><p>and in app.component.html, always next to the title</p><pre>&lt;fa-icon [icon]=&quot;[&#39;fas&#39;,&#39;pen-to-square&#39;]&quot;&gt;&lt;/fa-icon&gt;</pre><p>if it works</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*ZGF5DxiWy9y8StGi" /></figure><p>we have the 2 operational icon systems</p><p>To avoid adding all the libraries every time I create a component</p><pre>ng generate component fa-b</pre><pre>...</pre><pre>@Component({<br>  selector: &#39;ext-fa-b&#39;,  // ext = my prefix<br>  standalone: true,<br>  imports: [<br>    CommonModule,<br>    FontAwesomeModule,<br>  ],<br>  templateUrl: &#39;./fa-b.component.html&#39;,<br>  styleUrl: &#39;./fa-b.component.scss&#39;<br>})<br>export class FaBComponent {</pre><pre>  @Input() bi: string = &#39;&#39;;  // es: bi-alarm<br>  @Input() fa!: IconProp;  // es: [&#39;fas&#39;,&#39;pen-to-square&#39;]</pre><pre>  constructor(library: FaIconLibrary) {<br>    library.addIconPacks(faR.far, faS.fas);<br>  }<br>}</pre><pre>...</pre><pre>&lt;ng-container *ngIf=&quot;bi&quot;&gt;<br>    &lt;i [class]=&quot;bi&quot;&gt;&lt;/i&gt;<br>&lt;/ng-container&gt;<br>&lt;ng-container *ngIf=&quot;fa&quot;&gt;<br>    &lt;fa-icon [icon]=&quot;fa&quot;&gt;&lt;/fa-icon&gt;<br>&lt;/ng-container&gt;</pre><p>at least for any future modification I only have to modify component;</p><p>from app.component.ts I remove import and put only FaBComponent</p><pre>imports: [<br>    CommonModule,<br>    RouterOutlet,<br>    FaBComponent<br>  ],</pre><p>and on template only component that I can modify with classes</p><pre>&lt;ext-fa-b class=&quot;text-warning&quot; bi=&quot;bi-alarm&quot;&gt;&lt;/ext-fa-b&gt;<br>&lt;ext-fa-b class=&quot;text-danger&quot; [fa]=&quot;[&#39;fas&#39;,&#39;pen-to-square&#39;]&quot;&gt;&lt;/ext-fa-b&gt;</pre><blockquote><em>of course also applies to fontawesome</em></blockquote><pre>&lt;i class=&quot;fa-solid fa-pen-to-square&quot;&gt;&lt;/i&gt;</pre><h3>routing e basic admin template</h3><p>At this point I set up a basic routing skeleton</p><pre>home page<br>   sezione auth<br>      login<br>      otp<br>      logout<br>   sezione admin<br>      customers<br>         data<br>         analytics<br>         ...<br>      orders<br>         new order<br>         order list<br>         ...<br>      ...</pre><p>except home, and auth section, the graphic structure of the various pages is simple, nothing new:</p><ul><li>header -&gt; menu, monitor important data in context</li><li>left column -&gt; navigation bar</li><li>main container -&gt; application</li></ul><p>In the end the template looks like this with only 1 operational 2-level routing, customers -&gt; orders</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*KYWP5-axKQprF3y8" /></figure><p>admin demo template</p><p>It doesn’t have to be an eye-catching demo but a good ‘clean’ starting point that can be used without major cleaning/modification operations.</p><p>For the routing part app.routes.ts up to but not including the last component, use loadChildren</p><pre>export const routes: Routes = [<br>  {<br>    path: &#39;&#39;,<br>    loadChildren: () =&gt; import(&#39;./@t-sections/t-sections.module&#39;)<br>      .then(r =&gt; r.TSectionsModule),<br>  }<br>];</pre><p>and I added directive to insert dynamic components.</p><p>I’ll update soon with routing for auth and upload template to github.</p><p>…I forgot… why 17? it’s my date ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05127cf0a381" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>