<?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: Ikram Kharbouch</title>
    <description>The latest articles on DEV Community by Ikram Kharbouch (@ikramkharbouch).</description>
    <link>https://dev.to/ikramkharbouch</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%2F750851%2F03030d3b-ae60-4c70-8679-de74148f8dd8.jpeg</url>
      <title>DEV Community: Ikram Kharbouch</title>
      <link>https://dev.to/ikramkharbouch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ikramkharbouch"/>
    <language>en</language>
    <item>
      <title>Portfolio Update: A Fresh New Look &amp; Enhanced Features!</title>
      <dc:creator>Ikram Kharbouch</dc:creator>
      <pubDate>Sun, 17 Nov 2024 14:52:34 +0000</pubDate>
      <link>https://dev.to/ikramkharbouch/portfolio-update-a-fresh-new-look-enhanced-features-1024</link>
      <guid>https://dev.to/ikramkharbouch/portfolio-update-a-fresh-new-look-enhanced-features-1024</guid>
      <description>&lt;p&gt;Hey, Dev.to community! 👋&lt;/p&gt;

&lt;p&gt;I’m excited to share that I’ve just updated my portfolio with a fresh design and new features. I’ve been working hard to make it a better reflection of my skills and projects, and I’d love for you to check it out! Here’s what’s new:&lt;/p&gt;

&lt;p&gt;Modern Design &amp;amp; Smooth Navigation: Improved user experience.&lt;br&gt;
Showcasing My Latest Projects: Including the tech stacks and tools I’ve been working with.&lt;br&gt;
Fully Responsive: Optimized for mobile and desktop views.&lt;br&gt;
Updated Skills &amp;amp; Tools: Reflecting my current expertise.&lt;br&gt;
Custom Domain: ikramkharbouch.dev for a more professional touch!&lt;br&gt;
Feel free to visit and share your thoughts! 🙌&lt;br&gt;
🔗 Check it out here!&lt;/p&gt;

</description>
      <category>portfolio</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to create and connect to a firestore database in an express app ?</title>
      <dc:creator>Ikram Kharbouch</dc:creator>
      <pubDate>Tue, 22 Mar 2022 09:31:20 +0000</pubDate>
      <link>https://dev.to/ikramkharbouch/how-to-create-and-connect-to-a-firestore-database-in-an-express-app--4j84</link>
      <guid>https://dev.to/ikramkharbouch/how-to-create-and-connect-to-a-firestore-database-in-an-express-app--4j84</guid>
      <description>&lt;p&gt;As a web developer myself, I understand how hard it can be sometimes to find a simple guide that can help you do a specific thing you want, that's why I thought about making a simple guide to help newbies work with firebase's firestore database using expressjs.&lt;/p&gt;

&lt;p&gt;In this guide I am gonna show you all the necessary steps to create an expressjs app, create and connect to a firestore database, and then store some data for testing.&lt;/p&gt;

&lt;p&gt;First of all let's create an express app.&lt;/p&gt;

&lt;p&gt;Inside a folder run :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init &amp;amp;&amp;amp; npm install express --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file named index.js to initialize your express app.&lt;/p&gt;

&lt;p&gt;Next we need to install the firesbase-admin module inside of our express app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install firebase-admin --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The module that we just installed gives us access to some builtin methods that we gonna need to interact with our database, these methods are : initializeApp, cert, and getFirestore, destructure the mentioned methods using :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require("express");
const app = express();

const { initializeApp, cert } = require("firebase-admin/app");
const { getFirestore } = require("firebase-admin/firestore");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we need to create a firebase project in order to access to a firestore realtime database:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fso31fbsv091fojfejwm6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fso31fbsv091fojfejwm6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After creating a project named Sample-project, we should next create a web app to connect to firestore.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fvqjxzfvmvlizij8k1vi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fvqjxzfvmvlizij8k1vi0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After creating our webapp, we can then access the project overview to create our firestore database here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5elml729llzz1t6048n8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5elml729llzz1t6048n8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next thing we would need to do is to generate a new service account key to interact with our database, you can download here and name it whatever you want in your project, for my case I named it serviceAccountKey.json.&lt;/p&gt;

&lt;p&gt;Here we go to our project settings, then service accounts and click on  generate new key that is featured on the image below :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fhzi6qhn0zqxeww695ayy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fhzi6qhn0zqxeww695ayy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will get prompted to download your serviceAccountKey, and make sure to do it inside of your project.&lt;/p&gt;

&lt;p&gt;Next thing you need to include the key in your express app 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;const serviceAccount = require("./serviceAccountKey.json");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in order to initialize your app with admin privileges, you need to initialize your app this way :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;initializeApp({
  credential: cert(serviceAccount),
  databaseURL: process.env.databaseURL
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can get your database URL by simply adding your projectID + ".firebaseio.com"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F7bu4mzdk0e058vh5rm3k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F7bu4mzdk0e058vh5rm3k.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can get your project ID by simply browsing to your project settings as mentioned in the screenshot above.&lt;/p&gt;

&lt;p&gt;And finally, we went through all these steps to reach this last one, the one where we get our firestore instance that let's us communicate with our database from our app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const db = getFirestore();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now it's time to make our first request creating a new collection and inserting some documents into it for test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.post("/testDB", (req, res) =&amp;gt; {

let setDoc = 
db.collection('testCollection').doc('testDoc').set(req.body);

res.send({'Message': 'Success'});

});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope you enjoyed this guide, I am looking for your opinions about it, and if there is anything to add don't hesitate to comment about it, thank you :).&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>firebase</category>
      <category>firestore</category>
      <category>database</category>
    </item>
  </channel>
</rss>
