<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: chuongmep</title>
    <description>The latest articles on DEV Community by chuongmep (@chuongmep).</description>
    <link>https://dev.to/chuongmep</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F444802%2F95f3791d-9729-4ce4-8e75-4dbb0084455f.png</url>
      <title>DEV Community: chuongmep</title>
      <link>https://dev.to/chuongmep</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chuongmep"/>
    <language>en</language>
    <item>
      <title>Fix Loading module from ... was blocked because of a disallowed MIME type</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Wed, 12 Nov 2025 03:21:02 +0000</pubDate>
      <link>https://dev.to/chuongmep/fix-loading-module-from-was-blocked-because-of-a-disallowed-mime-type-543m</link>
      <guid>https://dev.to/chuongmep/fix-loading-module-from-was-blocked-because-of-a-disallowed-mime-type-543m</guid>
      <description>&lt;p&gt;This is simple way to fix : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find type format relate to the issue from console in web browser &lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;Add the code from python server, in my case I'm not able to load .mjs from source :
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mimetypes&lt;/span&gt;
&lt;span class="n"&gt;mimetypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;text/javascript&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.mjs&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>dev</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>Install NVM for Windows Without Administrator</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Wed, 03 Sep 2025 01:18:31 +0000</pubDate>
      <link>https://dev.to/chuongmep/install-nvm-for-windows-without-administrator-3c1e</link>
      <guid>https://dev.to/chuongmep/install-nvm-for-windows-without-administrator-3c1e</guid>
      <description>&lt;p&gt;Most tutorials for &lt;a href="https://github.com/coreybutler/nvm-windows/releases" rel="noopener noreferrer"&gt;nvm-windows&lt;/a&gt; assume you install it using the Windows installer, which requires &lt;strong&gt;administrator privileges&lt;/strong&gt;. But what if you can’t run installers or don’t have admin rights?&lt;/p&gt;

&lt;p&gt;Here’s a step-by-step guide to setting up &lt;strong&gt;NVM (Node Version Manager) for Windows&lt;/strong&gt; manually, without admin access.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Download NVM for Windows (No-Install)
&lt;/h2&gt;

&lt;p&gt;Go to the &lt;a href="https://github.com/coreybutler/nvm-windows/releases" rel="noopener noreferrer"&gt;nvm-windows releases page&lt;/a&gt; and download the &lt;strong&gt;&lt;code&gt;nvm-noinstall.zip&lt;/code&gt;&lt;/strong&gt; package.&lt;/p&gt;

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

&lt;p&gt;Extract it somewhere you can write to, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;D:\_WIP\Download\nvm-noinstall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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




&lt;h2&gt;
  
  
  2. Create &lt;code&gt;settings.txt&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Inside the extracted folder, create a new file called &lt;code&gt;settings.txt&lt;/code&gt; with this content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root: D:\_WIP\Download\nvm-noinstall
path: D:\_WIP\Download\nvm-noinstall\nodejs
arch: 64
proxy: none
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;This tells NVM where to keep Node.js versions and where the active Node.js binary should be symlinked.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Create the &lt;code&gt;nodejs&lt;/code&gt; Folder
&lt;/h2&gt;

&lt;p&gt;Still inside your extracted folder, create a new folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will be the folder NVM points to for the currently active Node.js version.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Install Node.js Using NVM
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;Command Prompt&lt;/strong&gt; (no admin needed) and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install &lt;/span&gt;latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will download and install the latest version of Node.js.&lt;/p&gt;

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




&lt;h2&gt;
  
  
  5. Setup Environment Variables
&lt;/h2&gt;

&lt;p&gt;Since you don’t have admin rights, you’ll set user-level environment variables.&lt;/p&gt;

&lt;p&gt;Add the following to your &lt;strong&gt;user environment variables&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;NVM_HOME&lt;/code&gt; → &lt;code&gt;D:\_WIP\Download\nvm-noinstall&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NVM_SYMLINK&lt;/code&gt; → &lt;code&gt;D:\_WIP\Download\nvm-noinstall\nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then, update your &lt;strong&gt;Path&lt;/strong&gt; (user-level) to include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%NVM_HOME%
%NVM_SYMLINK%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Tip: You &lt;strong&gt;don’t need&lt;/strong&gt; to set &lt;code&gt;nvm_symlink&lt;/code&gt; manually in environment variable, only &lt;code&gt;settings.txt&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Verify Installation
&lt;/h2&gt;

&lt;p&gt;Check available Node.js versions:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0idluazr4hjqlderlwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0idluazr4hjqlderlwr.png" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm list available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check installed versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch Node.js versions easily:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm use 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows" rel="noopener noreferrer"&gt;Microsoft Docs: Install Node.js on Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/coreybutler/nvm-windows/issues/22" rel="noopener noreferrer"&gt;nvm-windows GitHub Issue #22&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Bonus: What’s Next?
&lt;/h2&gt;

&lt;p&gt;If you’re looking at alternatives to Node.js, check out &lt;a href="https://bun.com/" rel="noopener noreferrer"&gt;Bun&lt;/a&gt; — a modern JavaScript runtime that is fast and has built-in tools like a bundler, transpiler, and test runner.&lt;/p&gt;




&lt;p&gt;Would you like me to make this &lt;strong&gt;more hands-on with a screenshot of environment variable setup and the &lt;code&gt;settings.txt&lt;/code&gt; file&lt;/strong&gt; so dev.to readers don’t get stuck?&lt;/p&gt;

</description>
      <category>dev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Fix FastAPI Debug Not Working in PyCharm on Windows</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Sun, 31 Aug 2025 13:25:56 +0000</pubDate>
      <link>https://dev.to/chuongmep/how-to-fix-fastapi-debug-not-working-in-pycharm-on-windows-5568</link>
      <guid>https://dev.to/chuongmep/how-to-fix-fastapi-debug-not-working-in-pycharm-on-windows-5568</guid>
      <description>&lt;p&gt;If you are developing a FastAPI application in PyCharm on Windows, you might run into this issue:&lt;/p&gt;

&lt;p&gt;Problem: You start the debugger, it runs, but code changes are not reflected on reload.&lt;/p&gt;

&lt;p&gt;I ran into this recently, and here’s what fixed it for me: downgrading Python from 3.12 to 3.11.&lt;/p&gt;

&lt;p&gt;Here’s the step-by-step solution:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new environment
In PyCharm, create a new virtual environment (e.g., .venv) using Python 3.11.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi8fv4eo29tovd9k3bcca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi8fv4eo29tovd9k3bcca.png" alt=" " width="624" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure Python Debug
Go to your Run/Debug Configurations and select the new environment. Make sure the “Python interpreter” points to your .venv.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ol&gt;
&lt;li&gt;Start Debug
Run the debugger. Now, changes in your code should properly reload and reflect in the application.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;This simple downgrade solved the reload issue on Windows.&lt;/p&gt;

</description>
      <category>pycharm</category>
      <category>python</category>
      <category>programming</category>
      <category>debug</category>
    </item>
    <item>
      <title>Azure Functions host did not return isolated worker process id. Macos</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Sat, 30 Aug 2025 11:11:52 +0000</pubDate>
      <link>https://dev.to/chuongmep/azure-functions-host-did-not-return-isolated-worker-process-id-macos-4fab</link>
      <guid>https://dev.to/chuongmep/azure-functions-host-did-not-return-isolated-worker-process-id-macos-4fab</guid>
      <description>&lt;h1&gt;
  
  
  Fixing .NET SDK Issue on macOS (ARM vs x64)
&lt;/h1&gt;

&lt;p&gt;I recently ran into an issue on macOS when working with .NET SDK.&lt;br&gt;
After some trial and error, I finally found the solution — and I hope this helps someone facing the same problem.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;When running .NET SDK on macOS with Apple Silicon (M1/M2), you might face compatibility issues if you install the wrong build of the SDK.&lt;br&gt;
At first, I installed the &lt;strong&gt;ARM64 version&lt;/strong&gt;, but some tools and workloads didn’t work properly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;You need to install the &lt;strong&gt;x64 version&lt;/strong&gt; of the .NET SDK instead of the ARM64 version.&lt;/p&gt;

&lt;p&gt;That small change fixed the problem completely.&lt;/p&gt;

&lt;p&gt;👉 You can grab the x64 build directly here:&lt;br&gt;
&lt;a href="https://dotnet.microsoft.com/en-us/download/dotnet/8.0" rel="noopener noreferrer"&gt;Download .NET 8 SDK&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why x64?
&lt;/h2&gt;

&lt;p&gt;Even though Apple Silicon supports ARM64, many tools, extensions, and third-party dependencies still expect x64 binaries. Running the x64 version of the SDK ensures better compatibility when developing on macOS.&lt;/p&gt;




&lt;p&gt;Would you like me to make it &lt;strong&gt;short and quick&lt;/strong&gt; (just the fix), or a &lt;strong&gt;longer version&lt;/strong&gt; with some explanation about Rosetta 2 and why x64 works better in this case?&lt;/p&gt;

</description>
      <category>macos</category>
      <category>azure</category>
      <category>api</category>
    </item>
    <item>
      <title>Change HomePage Azure Function .NET : Your Functions 4.0 app is up and running</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Thu, 03 Apr 2025 08:46:57 +0000</pubDate>
      <link>https://dev.to/chuongmep/change-homepage-azure-function-net-your-functions-40-app-is-up-and-running-1a49</link>
      <guid>https://dev.to/chuongmep/change-homepage-azure-function-net-your-functions-40-app-is-up-and-running-1a49</guid>
      <description>&lt;p&gt;I have some panic when I search from the internet to see how can we change the home page of Azure Function under .NET. In this post I will help you easy to change it some config and setting . &lt;/p&gt;

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

&lt;p&gt;You can change it by modifying the content using the &lt;code&gt;host.json&lt;/code&gt;.&lt;br&gt;
You need to add "extensions": { "http": { "routePrefix": "" } } in your host.json, Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"logging"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"applicationInsights"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"samplingSettings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"isEnabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"excludedTypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Request"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"enableLiveMetricsFilters"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"routePrefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now, you need to define a function return the home page information, in this example we will return the home page with result &lt;code&gt;Hello from Azure Function!&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"RootFunction"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IActionResult&lt;/span&gt; &lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;HttpTrigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AuthorizationLevel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anonymous&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"get"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;Route&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{ignored:maxlength(0)?}"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
            &lt;span class="n"&gt;HttpRequest&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;ignored&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"C# HTTP trigger function processed a request."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;OkObjectResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello from Azure Function!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when you look back after deployment, you can see the result. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4qqb9fqc1zxqfid7bow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4qqb9fqc1zxqfid7bow.png" alt=" " width="586" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy ! &lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/67180247/azure-functions-serving-content-for-root-url/76419027#76419027" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/67180247/azure-functions-serving-content-for-root-url/76419027#76419027&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>csharp</category>
      <category>azure</category>
      <category>restapi</category>
    </item>
    <item>
      <title>Install NVM Macos Easiest Way</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Wed, 26 Mar 2025 06:13:39 +0000</pubDate>
      <link>https://dev.to/chuongmep/easy-way-to-install-nvm-macos-2299</link>
      <guid>https://dev.to/chuongmep/easy-way-to-install-nvm-macos-2299</guid>
      <description>&lt;p&gt;I'm not sure why many posts and blog make problem more comlicated ,Let's use :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /tmp
curl &lt;span class="nt"&gt;-o-&lt;/span&gt; https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, after restart terminal, you can able to use it,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/oracle/graal/issues/8234" rel="noopener noreferrer"&gt;https://github.com/oracle/graal/issues/8234&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>macos</category>
      <category>dev</category>
    </item>
    <item>
      <title>How to setup Conda-Forge on macOS (Apple Silicon)</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Sat, 22 Mar 2025 07:01:27 +0000</pubDate>
      <link>https://dev.to/chuongmep/how-to-setup-conda-forge-on-macos-apple-silicon-4p37</link>
      <guid>https://dev.to/chuongmep/how-to-setup-conda-forge-on-macos-apple-silicon-4p37</guid>
      <description>&lt;h2&gt;
  
  
  Why Install Conda from Conda-Forge?
&lt;/h2&gt;

&lt;p&gt;Conda is a powerful package manager for Python and other languages, commonly used for data science, machine learning, and software development. While the default &lt;strong&gt;Anaconda&lt;/strong&gt; distribution is popular, the &lt;strong&gt;Conda-Forge&lt;/strong&gt; version provides a lightweight and community-driven alternative.&lt;/p&gt;

&lt;p&gt;If you're using an Apple Silicon Mac (M1/M2), installing &lt;strong&gt;Miniforge3&lt;/strong&gt; from Conda-Forge ensures better performance and compatibility.&lt;/p&gt;

&lt;p&gt;Conda-Forge can use under &lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Download Miniforge3 (Conda-Forge Version)
&lt;/h3&gt;

&lt;p&gt;Go to the official website: &lt;a href="https://conda-forge.org/download/" rel="noopener noreferrer"&gt;Conda-Forge Miniforge&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Download the installer for &lt;strong&gt;macOS (ARM64)&lt;/strong&gt;, which is optimized for Apple Silicon.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Install Miniforge3
&lt;/h3&gt;

&lt;p&gt;Once downloaded, open a terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash ~/Downloads/Miniforge3-MacOSX-arm64.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the on-screen instructions to complete the installation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Verify Installation
&lt;/h3&gt;

&lt;p&gt;After installation, check if Conda is installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/Users/your-username/miniforge3/bin/conda &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Replace &lt;code&gt;your-username&lt;/code&gt; with your actual username.)&lt;/p&gt;

&lt;p&gt;If Conda is installed correctly, you should see the version output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix: "Command Not Found" Issue After Installation
&lt;/h2&gt;

&lt;p&gt;If you get a "command not found" error when running &lt;code&gt;conda&lt;/code&gt;, follow these steps:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Add Conda to PATH
&lt;/h3&gt;

&lt;p&gt;Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH="/Users/your-username/miniforge3/bin:$PATH"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If using &lt;strong&gt;bash&lt;/strong&gt; instead of &lt;strong&gt;zsh&lt;/strong&gt;, replace &lt;code&gt;~/.zshrc&lt;/code&gt; with &lt;code&gt;~/.bashrc&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Initialize Conda for Your Shell
&lt;/h3&gt;

&lt;p&gt;Run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/Users/your-username/miniforge3/bin/conda init zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;strong&gt;bash&lt;/strong&gt;, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/Users/your-username/miniforge3/bin/conda init bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then restart your terminal.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Test Conda
&lt;/h3&gt;

&lt;p&gt;Try these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;conda &lt;span class="nt"&gt;--version&lt;/span&gt;
conda info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If they work, your installation is now properly configured!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Using &lt;strong&gt;Miniforge3&lt;/strong&gt; from Conda-Forge ensures a lightweight, Apple Silicon-optimized Conda installation. If you run into issues with &lt;code&gt;conda&lt;/code&gt; not being found, setting the correct PATH and initializing Conda should fix it. Enjoy your Conda-powered development environment on macOS!&lt;/p&gt;

</description>
      <category>condaforge</category>
      <category>python</category>
      <category>package</category>
      <category>programming</category>
    </item>
    <item>
      <title>Building a Secure Autodesk Platform Services (APS) API App: Session Management and Middleware Configuration</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Wed, 19 Mar 2025 05:20:36 +0000</pubDate>
      <link>https://dev.to/chuongmep/building-a-secure-autodesk-platform-services-aps-api-app-session-management-and-middleware-1khe</link>
      <guid>https://dev.to/chuongmep/building-a-secure-autodesk-platform-services-aps-api-app-session-management-and-middleware-1khe</guid>
      <description>&lt;h2&gt;
  
  
  Building a Secure Autodesk Platform Services (APS) API App: Session Management and Middleware Configuration
&lt;/h2&gt;

&lt;p&gt;When building applications with Autodesk Platform Services (APS), secure and persistent authentication is crucial for ensuring a smooth user experience. One of the key components in any web application is proper session management. In this post, we'll walk through how to set up session management using &lt;code&gt;express-session&lt;/code&gt; and &lt;code&gt;cookie-session&lt;/code&gt; while building an APS API app.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is Autodesk Platform Services (APS)?
&lt;/h3&gt;

&lt;p&gt;Autodesk Platform Services (APS) provides a cloud-based API platform that allows developers to integrate Autodesk tools into their applications. These APIs can be used for everything from model viewing to data exchange and file management, and they require proper authentication to ensure security.&lt;/p&gt;

&lt;p&gt;When building an APS application, handling OAuth 2.0 authentication is a critical part of the process. This typically involves handling access tokens, refresh tokens, and user sessions. For this reason, you need to carefully manage how session data is stored and accessed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Session Management in APS API Applications
&lt;/h3&gt;

&lt;p&gt;In APS, after you authenticate a user and obtain an access token, you typically need to manage the session to maintain the user’s login state. Session management involves storing the authentication data securely and making it available across multiple requests. This is where &lt;code&gt;express-session&lt;/code&gt; or &lt;code&gt;cookie-session&lt;/code&gt; come into play.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using &lt;code&gt;cookie-session&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;cookie-session&lt;/code&gt; is a lightweight solution where the session data is stored directly in the browser's cookies. It's perfect for smaller-scale apps or scenarios where session data doesn’t need to be too large. Here's a basic setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cookie-session&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SERVER_SESSION_SECRET&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./config.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Serve static files&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;static&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;wwwroot&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Session configuration using cookie-session&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;session&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SERVER_SESSION_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// A secret key to sign the cookie&lt;/span&gt;
    &lt;span class="na"&gt;maxAge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;             &lt;span class="c1"&gt;// Session expiration (1 day)&lt;/span&gt;
    &lt;span class="na"&gt;httpOnly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                          &lt;span class="c1"&gt;// Cookie can't be accessed via JS&lt;/span&gt;
    &lt;span class="na"&gt;secure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                           &lt;span class="c1"&gt;// Set to true if using HTTPS&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="c1"&gt;// Route handlers&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./routes/auth.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./routes/hubs.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Start the server&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server running on http://localhost:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this setup, the session data (like &lt;code&gt;refresh_token&lt;/code&gt; and user-specific data) will be stored in a cookie. The cookie will automatically be sent with every request, allowing you to retrieve and update session data without needing a database.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using &lt;code&gt;express-session&lt;/code&gt; for Larger Apps
&lt;/h4&gt;

&lt;p&gt;While &lt;code&gt;cookie-session&lt;/code&gt; is great for lightweight sessions, larger applications or those requiring more robust session handling might benefit from &lt;code&gt;express-session&lt;/code&gt;. This session middleware stores session data server-side, allowing for more complex and secure storage solutions like Redis or a database.&lt;/p&gt;

&lt;p&gt;Here’s how you can use &lt;code&gt;express-session&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;express-session
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And configure it in your app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-session&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SERVER_SESSION_SECRET&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./config.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Serve static files&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;static&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;wwwroot&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Session middleware configuration using express-session&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;session&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SERVER_SESSION_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// Secret key to sign the session cookie&lt;/span&gt;
    &lt;span class="na"&gt;resave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                           &lt;span class="c1"&gt;// Don't save session if not modified&lt;/span&gt;
    &lt;span class="na"&gt;saveUninitialized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                 &lt;span class="c1"&gt;// Create session even if it's empty&lt;/span&gt;
    &lt;span class="na"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;maxAge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;// Session expiration (1 day)&lt;/span&gt;
        &lt;span class="na"&gt;httpOnly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                      &lt;span class="c1"&gt;// Cookie can't be accessed via JS&lt;/span&gt;
        &lt;span class="na"&gt;secure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                       &lt;span class="c1"&gt;// Set to true if using HTTPS&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="c1"&gt;// Route handlers&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./routes/auth.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./routes/hubs.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Start the server&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server running on http://localhost:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration allows session data to be stored on the server (in memory, Redis, or another store), which is generally more secure for large applications. Unlike &lt;code&gt;cookie-session&lt;/code&gt;, &lt;code&gt;express-session&lt;/code&gt; doesn't store the actual session data in the cookie itself. Instead, it stores only a session ID, and the actual session data is kept server-side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Authentication Flow and Session Management
&lt;/h3&gt;

&lt;p&gt;After the user authenticates with APS via OAuth 2.0, you’ll typically handle tokens (access and refresh tokens) to maintain authentication. Here's an overview of the flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Initial Authentication&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user is redirected to Autodesk’s OAuth endpoint for authentication.&lt;/li&gt;
&lt;li&gt;Once authenticated, APS returns an authorization code, which is exchanged for an access token and refresh token.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Storing Tokens&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once you obtain the access and refresh tokens, you store them in the session so that they can be used in subsequent requests.&lt;/li&gt;
&lt;li&gt;This typically looks like this in your middleware:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;refresh_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;publicCredentials&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;refresh_token&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;access_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;publicCredentials&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;access_token&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Token Refresh&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the access token expires, you’ll need to use the refresh token to obtain a new access token. This involves checking the session for the stored refresh token and making a request to APS to refresh the session.&lt;/li&gt;
&lt;li&gt;Example of refreshing a token:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;expires_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;internalCredentials&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;authenticationClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refreshToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;refresh_token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;APS_CLIENT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="na"&gt;clientSecret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;APS_CLIENT_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="na"&gt;scopes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;INTERNAL_TOKEN_SCOPES&lt;/span&gt;
     &lt;span class="p"&gt;});&lt;/span&gt;
     &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;refresh_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;internalCredentials&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;refresh_token&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;access_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;internalCredentials&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;access_token&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Using Tokens in Requests&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After authenticating and refreshing tokens, you can use the session tokens to interact with the Autodesk APIs and access model data, manage files, and more.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Security Considerations
&lt;/h3&gt;

&lt;p&gt;When working with session management, especially in authentication-heavy apps, security is crucial. Here are some best practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use HTTPS&lt;/strong&gt;: Always use HTTPS for production to encrypt data in transit, including session cookies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secure Cookies&lt;/strong&gt;: Set the &lt;code&gt;secure: true&lt;/code&gt; option for cookies if you’re using HTTPS, ensuring cookies are only sent over secure connections.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session Expiry&lt;/strong&gt;: Use appropriate session expiry times (via &lt;code&gt;maxAge&lt;/code&gt;) to limit session duration and reduce the risk of stale sessions being hijacked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protect Against CSRF&lt;/strong&gt;: Ensure your app implements CSRF protection to prevent malicious requests from being sent on behalf of the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Session management is a crucial part of building secure and efficient Autodesk Platform Services apps. Whether you’re using &lt;code&gt;cookie-session&lt;/code&gt; for lightweight sessions or &lt;code&gt;express-session&lt;/code&gt; for more robust storage solutions, managing tokens and session data effectively will ensure that your application works seamlessly while maintaining security.&lt;/p&gt;

&lt;p&gt;With the correct session setup, you can easily manage user authentication, refresh tokens, and secure communication with Autodesk APIs—creating a smooth experience for your users.&lt;/p&gt;

</description>
      <category>autodesk</category>
      <category>aps</category>
      <category>javascript</category>
      <category>web</category>
    </item>
    <item>
      <title>Fix EACCES: permission denied, unlink '/usr/local/bin/code'</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Sat, 15 Mar 2025 04:00:55 +0000</pubDate>
      <link>https://dev.to/chuongmep/fix-eacces-permission-denied-unlink-usrlocalbincode-2464</link>
      <guid>https://dev.to/chuongmep/fix-eacces-permission-denied-unlink-usrlocalbincode-2464</guid>
      <description>&lt;p&gt;If you're using macOS and trying to run the shortcut command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;code &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to open the current folder in VS Code, but you get a permission error like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EACCES: permission denied, unlink '/usr/local/bin/code'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then you're not alone! This issue is quite common and happens because the &lt;code&gt;/usr/local/bin/code&lt;/code&gt; file requires administrative privileges to modify or delete.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Fix It
&lt;/h2&gt;

&lt;p&gt;To resolve this issue, follow these steps:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Remove the Existing &lt;code&gt;code&lt;/code&gt; Binary
&lt;/h3&gt;

&lt;p&gt;Since the file is in &lt;code&gt;/usr/local/bin/&lt;/code&gt;, you'll need admin permissions to remove it. Run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /usr/local/bin/code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter your password when prompted.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Reinstall the &lt;code&gt;code&lt;/code&gt; Command
&lt;/h3&gt;

&lt;p&gt;Now, reopen &lt;strong&gt;VS Code&lt;/strong&gt;, then follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;Command Palette&lt;/strong&gt; (&lt;code&gt;Cmd + Shift + P&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Search for &lt;strong&gt;Shell Command: Install 'code' command in PATH&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click on it to reinstall the CLI command.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Verify
&lt;/h3&gt;

&lt;p&gt;To confirm it's working, try running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;code &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see the version number of VS Code, then it's fixed! 🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  Notes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This fix requires &lt;strong&gt;admin permissions&lt;/strong&gt; to install the &lt;code&gt;code&lt;/code&gt; command properly.&lt;/li&gt;
&lt;li&gt;If you're using a &lt;strong&gt;non-admin account&lt;/strong&gt;, you may need to ask your system administrator for help.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, you can happily use &lt;code&gt;code .&lt;/code&gt; again without any issues! 🚀&lt;/p&gt;

&lt;p&gt;Let me know in the comments if you run into any trouble! Happy coding! 😊&lt;/p&gt;

</description>
      <category>macos</category>
      <category>vscode</category>
      <category>command</category>
    </item>
    <item>
      <title>AvaloniaUI Native AOT Deployment on Windows</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Fri, 21 Feb 2025 08:49:12 +0000</pubDate>
      <link>https://dev.to/chuongmep/avaloniaui-native-aot-deployment-on-windows-2jg1</link>
      <guid>https://dev.to/chuongmep/avaloniaui-native-aot-deployment-on-windows-2jg1</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Deploying an AvaloniaUI application with &lt;strong&gt;Native AOT (Ahead-Of-Time compilation)&lt;/strong&gt; on Windows can significantly improve startup performance and reduce the size of your application. However, due to Avalonia's reliance on &lt;strong&gt;reflection-based bindings&lt;/strong&gt;, Native AOT can cause runtime errors if not properly configured.&lt;/p&gt;

&lt;p&gt;This guide provides a step-by-step approach to resolving &lt;strong&gt;trimming issues&lt;/strong&gt; and ensuring a successful &lt;strong&gt;Native AOT&lt;/strong&gt; deployment for AvaloniaUI applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Issues and Fixes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;XAML Views Not Reachable via Runtime Loader&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you encounter the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Avalonia: XAML resource "avares://YourApp/Views/MainWindow.axaml" won't be reachable via runtime loader, as no public constructor was found.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  ✅ &lt;strong&gt;Fix:&lt;/strong&gt; Ensure Your Views Have a Public Constructor
&lt;/h4&gt;

&lt;p&gt;Each view must have a &lt;strong&gt;public parameterless constructor&lt;/strong&gt; in its &lt;code&gt;.axaml.cs&lt;/code&gt; file. Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;partial&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MainWindow&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Window&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;MainWindow&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;InitializeComponent&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. &lt;strong&gt;Ensure XAML Files Are Embedded Properly&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your UI does not load or throws missing resource errors, check your XAML file properties.&lt;/p&gt;

&lt;h4&gt;
  
  
  ✅ &lt;strong&gt;Fix:&lt;/strong&gt; Set Build Action to &lt;code&gt;AvaloniaResource&lt;/code&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Open &lt;strong&gt;Visual Studio&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Right-click your &lt;code&gt;.axaml&lt;/code&gt; file → Select &lt;strong&gt;Properties&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set &lt;strong&gt;Build Action&lt;/strong&gt; to &lt;code&gt;AvaloniaResource&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Fixing PublishTrimmed and Trimming Issues&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Since &lt;strong&gt;Native AOT automatically enables trimming&lt;/strong&gt;, Avalonia's &lt;strong&gt;reflection-based UI bindings&lt;/strong&gt; might get stripped out.&lt;/p&gt;

&lt;h4&gt;
  
  
  ✅ &lt;strong&gt;Fix:&lt;/strong&gt; Add &lt;code&gt;TrimmerRootAssembly&lt;/code&gt; in &lt;code&gt;.csproj&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;To prevent Avalonia's essential assemblies from being trimmed, modify your &lt;code&gt;.csproj&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TrimmerRootAssembly&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"Avalonia.Controls"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TrimmerRootAssembly&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"Avalonia.Base"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TrimmerRootAssembly&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"Avalonia.Markup.Xaml"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. &lt;strong&gt;Project Configuration&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;PropertyGroup&amp;gt;
        &amp;lt;OutputType&amp;gt;WinExe&amp;lt;/OutputType&amp;gt;
        &amp;lt;TargetFramework&amp;gt;net8.0&amp;lt;/TargetFramework&amp;gt;
        &amp;lt;Nullable&amp;gt;enable&amp;lt;/Nullable&amp;gt;
        &amp;lt;PublishReadyToRun&amp;gt;true&amp;lt;/PublishReadyToRun&amp;gt;
        &amp;lt;PublishAot&amp;gt;true&amp;lt;/PublishAot&amp;gt;
        &amp;lt;EventSourceSupport&amp;gt;true&amp;lt;/EventSourceSupport&amp;gt;
        &amp;lt;IsAotCompatible&amp;gt;true&amp;lt;/IsAotCompatible&amp;gt;
        &amp;lt;!-- Recommended Avalonia trimming settings for Native AOT --&amp;gt;
        &amp;lt;!--    &amp;lt;BuiltInComInteropSupport&amp;gt;false&amp;lt;/BuiltInComInteropSupport&amp;gt;--&amp;gt;
        &amp;lt;!--    &amp;lt;IncludeNativeLibrariesForSelfExtract&amp;gt;true&amp;lt;/IncludeNativeLibrariesForSelfExtract&amp;gt;--&amp;gt;
        &amp;lt;TrimMode&amp;gt;partial&amp;lt;/TrimMode&amp;gt;
        &amp;lt;ApplicationManifest&amp;gt;app.manifest&amp;lt;/ApplicationManifest&amp;gt;
        &amp;lt;StripSymbols&amp;gt;false&amp;lt;/StripSymbols&amp;gt;
        &amp;lt;AvaloniaUseCompiledBindingsByDefault&amp;gt;true&amp;lt;/AvaloniaUseCompiledBindingsByDefault&amp;gt;
        &amp;lt;AppendTargetFrameworkToOutputPath&amp;gt;false&amp;lt;/AppendTargetFrameworkToOutputPath&amp;gt;
    &amp;lt;/PropertyGroup&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Building and Publishing for Native AOT&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Run the following command to &lt;strong&gt;publish&lt;/strong&gt; your Avalonia app with Native AOT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet publish &lt;span class="nt"&gt;-r&lt;/span&gt; win-x64 &lt;span class="nt"&gt;-c&lt;/span&gt; Release &lt;span class="nt"&gt;--self-contained&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt;:PublishAot&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Final Checklist for Native AOT Deployment&lt;/strong&gt; ✅
&lt;/h2&gt;

&lt;p&gt;✔ &lt;strong&gt;Ensure all views have a public constructor&lt;/strong&gt;&lt;br&gt;
✔ &lt;strong&gt;Set XAML files to &lt;code&gt;AvaloniaResource&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
✔ &lt;strong&gt;Prevent trimming of required Avalonia assemblies (&lt;code&gt;TrimmerRootAssembly&lt;/code&gt;)&lt;/strong&gt;&lt;br&gt;
✔ &lt;strong&gt;Use &lt;code&gt;rd.xml&lt;/code&gt; to preserve Avalonia reflection-based types&lt;/strong&gt;&lt;br&gt;
✔ &lt;strong&gt;Properly initialize Avalonia in &lt;code&gt;App.axaml.cs&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
✔ &lt;strong&gt;Publish using &lt;code&gt;dotnet publish -p:PublishAot=true&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;By following these steps, you can &lt;strong&gt;successfully deploy AvaloniaUI applications using Native AOT&lt;/strong&gt; on Windows without breaking essential functionality. This ensures a &lt;strong&gt;smaller, faster&lt;/strong&gt; application while avoiding common pitfalls with Avalonia’s reflection-heavy UI framework.&lt;/p&gt;

&lt;p&gt;For further details, refer to the official documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.avaloniaui.net/docs/deployment/native-aot" rel="noopener noreferrer"&gt;AvaloniaUI Native AOT Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/" rel="noopener noreferrer"&gt;Microsoft .NET Native AOT Deployment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>wpf</category>
      <category>ui</category>
      <category>avalonia</category>
    </item>
    <item>
      <title>Comparing JSON Libraries in .NET: Newtonsoft.Json vs. System.Text.Json</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Thu, 20 Feb 2025 01:15:49 +0000</pubDate>
      <link>https://dev.to/chuongmep/comparing-json-libraries-in-net-newtonsoftjson-vs-systemtextjson-3gfo</link>
      <guid>https://dev.to/chuongmep/comparing-json-libraries-in-net-newtonsoftjson-vs-systemtextjson-3gfo</guid>
      <description>&lt;p&gt;When working with JSON in .NET, two popular libraries are &lt;strong&gt;Newtonsoft.Json&lt;/strong&gt; (also known as Json.NET) and &lt;strong&gt;System.Text.Json&lt;/strong&gt;. Below, we compare their usage for reading and parsing JSON data.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;strong&gt;Newtonsoft.Json&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Reading and Parsing JSON&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Install-Package Newtonsoft.Json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Deserialize JSON to Object&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Newtonsoft.Json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Token&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;AccessToken&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;RefreshToken&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ExpiresIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{ 'access_token': 'abc123', 'refresh_token': 'def456', 'expires_in': 3600 }"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonConvert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeserializeObject&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AccessToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Output: abc123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Reading JSON from a File&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;jsonContent&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ReadAllText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"token.json"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonConvert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeserializeObject&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;jsonContent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Using JObject for Dynamic Access&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Newtonsoft.Json.Linq&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{ 'access_token': 'abc123', 'refresh_token': 'def456', 'expires_in': 3600 }"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;JObject&lt;/span&gt; &lt;span class="n"&gt;tokenData&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonConvert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeserializeObject&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;JObject&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;accessToken&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tokenData&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"access_token"&lt;/span&gt;&lt;span class="p"&gt;]?.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. &lt;strong&gt;System.Text.Json&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Reading and Parsing JSON&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;br&gt;
System.Text.Json is included in .NET Core 3.0 and later versions, so no additional installation is needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Deserialize JSON to Object&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Text.Json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Token&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;AccessToken&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;RefreshToken&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ExpiresIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{ \"access_token\": \"abc123\", \"refresh_token\": \"def456\", \"expires_in\": 3600 }"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonSerializer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Deserialize&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AccessToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Output: abc123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Reading JSON from a File&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;jsonContent&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ReadAllText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"token.json"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;Token&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonSerializer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Deserialize&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;jsonContent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Using JsonDocument for Dynamic Access&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Text.Json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{ \"access_token\": \"abc123\", \"refresh_token\": \"def456\", \"expires_in\": 3600 }"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;JsonDocument&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonDocument&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;JsonElement&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RootElement&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;accessToken&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"access_token"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;GetString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Comparison Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Newtonsoft.Json&lt;/th&gt;
&lt;th&gt;System.Text.Json&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Installation&lt;/td&gt;
&lt;td&gt;Requires separate NuGet package&lt;/td&gt;
&lt;td&gt;Built-in with .NET Core 3.0+&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deserialization&lt;/td&gt;
&lt;td&gt;&lt;code&gt;JsonConvert.DeserializeObject&amp;lt;T&amp;gt;()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;JsonSerializer.Deserialize&amp;lt;T&amp;gt;()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic Access&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;JObject&lt;/code&gt; for flexible JSON access&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;JsonDocument&lt;/code&gt; for read-only access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Null Handling&lt;/td&gt;
&lt;td&gt;More configurable options&lt;/td&gt;
&lt;td&gt;Default ignore nulls with options&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Slower than System.Text.Json&lt;/td&gt;
&lt;td&gt;Generally faster and more efficient&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why AOT Needs to Use System.Text.Json&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Ahead-Of-Time (AOT) Compilation&lt;/strong&gt; is a technique used to improve performance by compiling code before runtime. &lt;strong&gt;System.Text.Json&lt;/strong&gt; is designed to work seamlessly with AOT in .NET, providing the following benefits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced Memory Footprint&lt;/strong&gt;: System.Text.Json is more lightweight, which helps in minimizing memory usage during compilation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Faster Startup Times&lt;/strong&gt;: AOT compilation with System.Text.Json can lead to faster application startup times because the JSON handling is optimized and compiled ahead of time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Native Support&lt;/strong&gt;: Being a part of the .NET core libraries, System.Text.Json is optimized for performance and compatibility with AOT compilation, reducing the risk of runtime issues compared to third-party libraries like Newtonsoft.Json.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhanced Performance&lt;/strong&gt;: System.Text.Json typically offers better performance due to optimizations for serialization and deserialization, which is critical for applications that rely heavily on JSON data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Both &lt;strong&gt;Newtonsoft.Json&lt;/strong&gt; and &lt;strong&gt;System.Text.Json&lt;/strong&gt; have their strengths. Use &lt;strong&gt;Newtonsoft.Json&lt;/strong&gt; for complex scenarios and flexibility, and consider &lt;strong&gt;System.Text.Json&lt;/strong&gt; for better performance, native support in .NET Core, and seamless integration with AOT compilation.&lt;/p&gt;

</description>
      <category>json</category>
      <category>net</category>
      <category>programming</category>
      <category>data</category>
    </item>
    <item>
      <title>Resolve 'IBM437' is not a supported encoding name EPPlus</title>
      <dc:creator>chuongmep</dc:creator>
      <pubDate>Wed, 05 Feb 2025 07:56:32 +0000</pubDate>
      <link>https://dev.to/chuongmep/resolve-ibm437-is-not-a-supported-encoding-name-epplus-36bi</link>
      <guid>https://dev.to/chuongmep/resolve-ibm437-is-not-a-supported-encoding-name-epplus-36bi</guid>
      <description>&lt;p&gt;First add a reference to System.Text.Encoding.CodePages assembly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ItemGroup&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;PackageReference&lt;/span&gt; &lt;span class="n"&gt;Include&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"System.Text.Encoding.CodePages"&lt;/span&gt; &lt;span class="n"&gt;Version&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"4.3.0"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ItemGroup&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Then register the missing parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt; &lt;span class="n"&gt;Encoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;RegisterProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CodePagesEncodingProvider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Instance&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/JanKallman/EPPlus/issues/31" rel="noopener noreferrer"&gt;https://github.com/JanKallman/EPPlus/issues/31&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>excel</category>
      <category>epplus</category>
    </item>
  </channel>
</rss>
