<?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: abdulrahilsheikh</title>
    <description>The latest articles on DEV Community by abdulrahilsheikh (@abdulrahilsheikh).</description>
    <link>https://dev.to/abdulrahilsheikh</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1099426%2F2447827d-4bf7-4be8-ab21-f5d11131b580.jpeg</url>
      <title>DEV Community: abdulrahilsheikh</title>
      <link>https://dev.to/abdulrahilsheikh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdulrahilsheikh"/>
    <language>en</language>
    <item>
      <title>Fixing HTTPS Certificates in .NET Dev Containers (The Right Way)</title>
      <dc:creator>abdulrahilsheikh</dc:creator>
      <pubDate>Thu, 08 Oct 2026 11:17:13 +0000</pubDate>
      <link>https://dev.to/abdulrahilsheikh/fixing-https-certificates-in-net-dev-containers-the-right-way-1nie</link>
      <guid>https://dev.to/abdulrahilsheikh/fixing-https-certificates-in-net-dev-containers-the-right-way-1nie</guid>
      <description>&lt;p&gt;Project Directory Structure&lt;br&gt;
Before we dive into the commands, here is what your repository layout looks like, showing where the .NET backend code resides under the server/ folder and where the generated certificate will live:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet_learning/
├── .devcontainer/
│   ├── devcontainer.json
│   └── docker-compose.yml
├── server/                    &amp;lt;-- .NET Backend Project Folder
│   ├── certs/
│   │   └── localhost.pfx      &amp;lt;-- Generated &amp;amp; mounted PFX certificate
│   ├── Controllers/
│   ├── Program.cs
│   └── Server.csproj
├── next_ui/                   &amp;lt;-- Frontend (React/Next.js)
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Problem: Certificates in Isolated Environments
&lt;/h2&gt;

&lt;p&gt;When you spin up a Dev Container, it runs inside an isolated Linux environment (usually Debian or Ubuntu). Your host machine's trusted certificate store isn't automatically shared with the container.&lt;/p&gt;

&lt;p&gt;If you try to run the standard .NET certificate command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet dev-certs https &lt;span class="nt"&gt;--trust&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;It might fail or fail to persist outside the container lifecycle, leaving your browser or API clients complaining about untrusted certificates (&lt;code&gt;ERR_CERT_AUTHORITY_INVALID&lt;/code&gt;).&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Clean the Slate (Just in Case)
&lt;/h2&gt;

&lt;p&gt;If you've been messing around with existing certificates and hitting weird errors, start by clearing out any corrupted state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet dev-certs https &lt;span class="nt"&gt;--clean&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: If you run into a strange &lt;code&gt;Interop.Sys.GetCwdHelper&lt;/code&gt; error on macOS/Linux while doing this, it usually means your terminal's current working directory got unlinked. Simply run &lt;code&gt;cd ~ &amp;amp;&amp;amp; cd -&lt;/code&gt; to reset your shell's path, then try again).&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Generate and Export a &lt;code&gt;.pfx&lt;/code&gt; Certificate
&lt;/h2&gt;

&lt;p&gt;Instead of relying solely on the container's auto-generated store, you can explicitly export a password-protected &lt;code&gt;.pfx&lt;/code&gt; file from your host machine that you can mount into your container.&lt;/p&gt;

&lt;p&gt;Open your terminal, make sure you are in your project's root folder (workspace root). Run the following command on your host machine to generate the cert and save it inside your project's &lt;code&gt;server/certs/&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet dev-certs https &lt;span class="nt"&gt;-ep&lt;/span&gt; ./server/certs/localhost.pfx &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Password"&lt;/span&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-ep ./server/certs/localhost.pfx&lt;/code&gt;: Exports the certificate to your project path.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-p "Password"&lt;/code&gt;: Sets a password to protect the private key inside the PFX bundle.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 3: Trust the Certificate inside the Container
&lt;/h2&gt;

&lt;p&gt;Right after generating your certificate runn the below command, to make sure your host machine trusts the development certificate so your browser and host tools don't throw security errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet dev-certs https &lt;span class="nt"&gt;--trust&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: Depending on your OS—macOS, Windows, or Linux—this will prompt you for your user password or system administrator permissions to install the development certificate into your host's trusted root authority store.)&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Configure it in your &lt;code&gt;devcontainer.json&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;To make your container use this certificate automatically, you need to configure two things in your &lt;code&gt;.devcontainer/devcontainer.json&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;mounts&lt;/code&gt;&lt;/strong&gt;: To bind-mount the &lt;code&gt;.pfx&lt;/code&gt; file from your host into the container's file system (e.g., &lt;code&gt;/certs/localhost.pfx&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;containerEnv&lt;/code&gt;&lt;/strong&gt;: To tell Kestrel where to find the certificate using ASP.NET Core environment variables.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is how your &lt;code&gt;devcontainer.json&lt;/code&gt; should look with the certificate mounts and environment configurations injected:&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="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;For&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;format&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;details,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;see&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;https://aka.ms/devcontainer.json.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;For&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;options,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;see&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;README&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;at:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;https://github.com/devcontainers/templates/tree/main/src/dotnet-postgres&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;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"C# (.NET) and PostgreSQL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dockerComposeFile"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"docker-compose.yml"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"service"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"workspaceFolder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/workspaces/${localWorkspaceFolderBasename}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"features"&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;"ghcr.io/devcontainers/features/node:2"&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;"nodeGypDependencies"&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;"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;"lts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"npmVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"lts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"pnpmVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"latest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"nvmVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"latest"&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;"mounts"&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="s2"&gt;"source=node_modules_vol,target=${containerWorkspaceFolder}/next_ui/node_modules,type=volume"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Mount&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;generated&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;PFX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;certificate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;into&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;container&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"source=${localWorkspaceFolder}/server/certs/localhost.pfx,target=/certs/localhost.pfx,type=bind"&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;"customizations"&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;"vscode"&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="s2"&gt;"ms-dotnettools.csharp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"ms-dotnettools.cs-dev-kit"&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;span class="nl"&gt;"postCreateCommand"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sudo chown -R vscode:vscode /workspaces/dotnet_learning/next_ui/node_modules || true"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Configure&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Kestrel&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;use&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;mounted&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;certificate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;via&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;environment&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;variables&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"containerEnv"&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;"ASPNETCORE_Kestrel__Certificates__Default__Path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/certs/localhost.pfx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"ASPNETCORE_Kestrel__Certificates__Default__Password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Password"&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;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Handling SSL certificates in Docker containers can be frustrating, but by generating a &lt;code&gt;.pfx&lt;/code&gt; file on your host, binding it via &lt;code&gt;mounts&lt;/code&gt;, and configuring Kestrel through &lt;code&gt;containerEnv&lt;/code&gt;, your .NET app will run smoothly with fully trusted HTTPS inside your Dev Container! &lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>dotnet</category>
      <category>security</category>
    </item>
    <item>
      <title>Creating an Express.js App Using Typescript &amp; MongoDb P-1</title>
      <dc:creator>abdulrahilsheikh</dc:creator>
      <pubDate>Wed, 05 Jul 2023 10:38:18 +0000</pubDate>
      <link>https://dev.to/abdulrahilsheikh/creating-an-expressjs-app-using-typescript-mongodb-p-1-1ha3</link>
      <guid>https://dev.to/abdulrahilsheikh/creating-an-expressjs-app-using-typescript-mongodb-p-1-1ha3</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Section 1 - Creating Express App&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step by step Implementation:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Step 1 :&lt;/strong&gt; First create a empty folder and open terminal in this folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 :&lt;/strong&gt; Run the following command in your terminal, to create a nodejs application, because our express server will work inside the node application.&lt;br&gt;
&lt;em&gt;Command :&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Step 3 :&lt;/strong&gt; Installing all the necessary dependencies for our application.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Command :&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install express cors mongoose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Step 4 :&lt;/strong&gt; Now we need to install types for express and cors.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @types/express @types/cors --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Step 5 :&lt;/strong&gt; Now we have to set up typescript for our app for that run the following command&lt;br&gt;
&lt;em&gt;Command :&lt;/em&gt;     &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tsc --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This will create a tsconfig.json file which will have all the configuration for the typescript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6 :&lt;/strong&gt; Now to run the typescript application we need to install some additional dependencies. Which are ts-node and nodemon.&lt;br&gt;
 &lt;em&gt;Command :&lt;/em&gt;    &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i nodemon ts-node --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;After following all the steps your folder structure should look like&lt;/strong&gt;&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%2Fwgaq3k9v53sdus0ck9cs.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%2Fwgaq3k9v53sdus0ck9cs.png" alt="Folder structure" width="279" height="104"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-|-node_modules
 |-package-lock.json
 |-package.json
 |-tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Step 7 :&lt;/strong&gt; Creating an entry point for our express app to start.&lt;br&gt;
create an index,ts file in the root of your project. Also create a folder with app name here we will put all of our middleware, routes etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The project structure will look like following.&lt;/strong&gt;&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%2F898bifbc49e5v4haot9r.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%2F898bifbc49e5v4haot9r.png" alt="Image showing folder structure 2" width="286" height="175"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-|-app
 |-node_modules
 |-index.ts
 |-package-lock.json
 |-package.json
 |-tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt; To run the server we need to add following script to our package.json file. Also change the extension on index.js to index.ts of the main property in package.json. &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"run:dev": "nodemon index.ts"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;After this our script will look like&lt;/strong&gt; &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%2Fldivk85btbqv22gg8qjc.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%2Fldivk85btbqv22gg8qjc.png" alt="Package Json after editing" width="591" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9:&lt;/strong&gt; Now to test our setup is working file put the below code snippet in the index.ts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("I'm running")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in the terminal run the following command&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The text &lt;strong&gt;I'm running&lt;/strong&gt; should log in the terminal and your terminal should look like following.&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%2Flrzdcycgfm7t7u3t4qgu.jpg" 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%2Flrzdcycgfm7t7u3t4qgu.jpg" alt="Server run 1" width="609" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hurray 🎉🎊🎉 we have successfully setup our starting point&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10:&lt;/strong&gt; Now create a app.ts file in app folder. The folder structure will look like following.&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%2Fyjbbsz306kbksnoass6f.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%2Fyjbbsz306kbksnoass6f.png" alt="folder structure 3" width="272" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-|-app
 |   |-app.ts
 |-node_modules
 |-index.ts
 |-package-lock.json
 |-package.json
 |-tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 11:&lt;/strong&gt; Now need to create our express server. For that we need an instance of express. For that we need to import express from express package we installed. for that put the below code at the top of app.ts file.&lt;br&gt;
And now invoke this express function imported and store it into a variable named app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from "express";

const app: express.Application = express();

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

&lt;/div&gt;



&lt;p&gt;express.Application will give us typescript interface of express&lt;/p&gt;

&lt;p&gt;Now create a function named server and export it. We will use this server function in index.ts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from "express";

const app: express.Application = express();
export const server = async () =&amp;gt; {
    const port: number = 3500;
    app.listen(port, () =&amp;gt; {
        console.log(`Server running on ${port}`);
    });
};

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

&lt;/div&gt;



&lt;p&gt;Now in index.ts import the server and invoke it as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { server } from "./app/app";

server();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now again run the npm run run:dev to start the server in dev mode.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Your terminal will look like following.&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%2Ftimatk3it03fhvmivkn4.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%2Ftimatk3it03fhvmivkn4.png" alt="Server run 2" width="512" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 12:&lt;/strong&gt;  Now we will create a basic get route which will return hello world. For doing first we will create an organized folder structure . For that we will create a modules folder inside our app folder for holding our routes. In this modules folder create a new folder called users. Inside it create files called users.routes.ts, users.schema.ts and users.services.ts  . Now you folder should look like following.&lt;br&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%2F6i32r7sr29kp40iymfso.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%2F6i32r7sr29kp40iymfso.png" alt="folder structure 3" width="242" height="300"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-|-app
 |   |-modules
 |   |    |-users
 |   |       |-users.routes.ts
 |   |       |-users.schema.ts
 |   |       |-users.services.ts
 |   |-app.ts
 |-node_modules
 |-index.ts
 |-package-lock.json
 |-package.json
 |-tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Each file has its own role. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; users.routes.ts will hold all the routes such as get, post, patch etc.&lt;/li&gt;
&lt;li&gt;users.schema.ts will hold the mongoose schema and model which we will use to communicate with mongodb.&lt;/li&gt;
&lt;li&gt;users.services.ts will hold the all function which we need to complete or process the user request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 13:&lt;/strong&gt; In user.routes.ts import the Router from express and create an instance of it.&lt;br&gt;
Router function is used to create a new router object which is used to create a new router object in your program to handle requests. &lt;br&gt;
Your code should look like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Router } from "express";

const userRouter = Router();

userRouter.get("/users", (req, res) =&amp;gt; {
    res.json({ message: "sent succesfully" });
});

export default userRouter;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now import this user router in your app.ts file and use is as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from "express";
import userRouter from "./modules/users/users.routes";

const app: express.Application = express();
export const server = async () =&amp;gt; {
    const port: number = 3500;
    app.use('/',userRouter);
    app.listen(port, () =&amp;gt; {
        console.log(`Server running on ${port}`);
    });
};

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

&lt;/div&gt;



&lt;p&gt;Now in your browser go to http:localhost:3500/users or whatever your port is http:localhost:/users.&lt;br&gt;
You will see the following.&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%2Feriyzgx8kylgjis2601h.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%2Feriyzgx8kylgjis2601h.png" alt="Browser view 1" width="511" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations 🎊🎉 you've successfully created a route. You can similarly create a post route.&lt;/p&gt;

&lt;p&gt;Now we will use the services file.&lt;br&gt;
The services file will have all the business logic like processing data, fetching from db etc.&lt;br&gt;
In users.services.ts paste the following code block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const users = [
    { name: "Jhon Doe", age: 24 },
    { name: "Man Freed", age: 22 },
    { name: "Mr Beast", age: 21 },
    { name: "Carry Minati", age: 25 },
];

export const getRandomUser = () =&amp;gt; {
    const index = Math.floor(Math.random() * users.length);
    return users[index];
};

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

&lt;/div&gt;



&lt;p&gt;Also modify the user.routes.ts like the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Router } from "express";
import { getRandomUser } from "./users.services";

const userRouter = Router();

userRouter.get("/users", (req, res) =&amp;gt; {
    const user = getRandomUser();
    res.json({ user });
});

export default userRouter;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now each time you hit "/users" or refresh the page in browser you will get a different user.&lt;br&gt;
We will be using this services a lot when dealing with mongodb.&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%2Frlmuhekd2d0wbjn3f937.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%2Frlmuhekd2d0wbjn3f937.png" alt="Browser view 2" width="335" height="135"&gt;&lt;/a&gt;&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%2Fv6f6nga2joqp106imo2e.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%2Fv6f6nga2joqp106imo2e.png" alt="Browser view 3" width="324" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For connecting to mongodb and using it we will have another blog. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
