<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by SIHEM BOUHENNICHE on Medium]]></title>
        <description><![CDATA[Stories by SIHEM BOUHENNICHE on Medium]]></description>
        <link>https://medium.com/@fs_bouhenniche?source=rss-a535af0e2f00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xlMELkjBXaAVeu-H6MaRqg.jpeg</url>
            <title>Stories by SIHEM BOUHENNICHE on Medium</title>
            <link>https://medium.com/@fs_bouhenniche?source=rss-a535af0e2f00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:43:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fs_bouhenniche/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Publish Your Android Library to GitLab Registry with CI/CD Pipeline]]></title>
            <link>https://javascript.plainenglish.io/publish-your-android-library-to-gitlab-registry-with-ci-cd-pipeline-7ac34563ae40?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ac34563ae40</guid>
            <category><![CDATA[gitlab-ci]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 14:43:10 GMT</pubDate>
            <atom:updated>2024-07-17T01:20:20.313Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2P6K3PICYSDMQ9dJ5F_UtQ.png" /></figure><p>If you’ve created a useful Android library and want to share it within your team or use it in multiple projects, you’re in the right place. This tutorial will walk you through the entire process, from setting up your library module to configuring an automated CI/CD pipeline that handles building and publishing for you as a Maven library in the GitLab package registry. In this guide, we will:</p><ol><li>Create a simple Android library module named euclideanOperationsLib.</li><li>Configure the library for publication to the GitLab registry.</li><li>Set up a GitLab CI/CD pipeline for automated building and publishing.</li><li>Demonstrate how to use the published library in your projects.</li></ol><h4>1. Create Android library</h4><p>In Android Studio, we will start by creating an empty activity application named My Application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rgJ67hYeuUncD2zK7EAG5A.png" /><figcaption>Creation of My Application</figcaption></figure><p>Then, we create a new module inside this Android project. The module type should be “Android Library” and we will name it euclideanOperationsLib, which will contain some basic Euclidean operations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*2JbiL0fLHy1jYNKjJgYDig.png" /><figcaption>Creation of Android Library</figcaption></figure><p>Inside the com.example.euclideanoperationslib folder, create a new file named EuclideanOperationsUtils.kt that will contain our code:</p><pre>@file:JvmName(&quot;EuclideanOperationsUtils&quot;)<br><br>package com.example.euclideanoperationslib<br><br>// This is a simple utility class that provides methods to calculate basic euclidean operations<br>fun addOp(a: Int, b: Int): Int = a + b<br><br>fun multiplyOp(a: Int, b: Int): Int = a * b<br><br>fun minusOp(a: Int, b: Int): Int = a - b<br><br>fun divideOp(a: Int, b: Int): Int {<br>    if (b == 0) throw IllegalArgumentException(&quot;Divider cannot be 0&quot;)<br>    return a / b<br>}</pre><p>After that, let’s use our library in our application. To do so, we should add a plugin dependency in the build.gradle file of &quot;My Application&quot; at the module level like this:</p><pre>implementation(project(&quot;:euclideanOperationsLib&quot;))</pre><p>Then, we can use it inside the “My Application” module, for example in the MainActivity class:</p><pre>...<br>import com.example.euclideanoperationslib.addOp<br><br>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        Log.i(&quot;TEST&quot;,&quot;Testing addOp: ${addOp(1, 2)}&quot;)<br>...</pre><p>For more information on how to create an Android library, you can refer to the official Android documentation :</p><p><a href="https://developer.android.com/studio/projects/android-library#kts">Create an Android library | Android Studio | Android Developers</a></p><p>Finally, we build our project in order to generate the .aar file:</p><pre>./gradlew build</pre><p>This will generate .aar artifacts, which can be found inside build/outputs/aar.</p><h4>2. Configure the Library for Publication to the GitLab Registry</h4><p>The first step is to create a GitLab project. In GitLab.com, let’s create a new blank project named euclideanOperations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bY_hylT8njSLLMF_oEsfrA.png" /><figcaption>Creation of Gitlab project</figcaption></figure><p>According to the documentation, we should use one of these tokens to push any package to the Maven registry:</p><ul><li>Personal access token</li><li>Deploy token</li><li>CI Job token (We will use this token when we set up the GitLab CI/CD pipeline)</li></ul><p>For now, let’s create a new Deploy token that we will use to push our library .aar file to the Maven registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gDEIOPymsQfdH0mvjhATTg.png" /><figcaption>Deploy Token creation</figcaption></figure><p>Now, let’s return to our project and create a new configuration file at the root folder of our project named gradle-mvn-push.gradle with the following content:</p><pre>// Apply the Maven Publish plugin<br>apply plugin: &#39;maven-publish&#39;<br><br>// Configure the publishing task<br>publishing {<br>    publications {<br>        // Define a publication named &quot;myPublish&quot;<br>        myPublish(MavenPublication) {<br>            // Set the group, artifact, and version identifiers<br>            groupId &quot;com.example.euclideanoperationslib&quot;<br>            artifactId &quot;euclideanOperationsLib&quot;<br>            version &quot;1.0.0&quot;<br>            <br>            // Specify the artifact to be published<br>            artifact &quot;$buildDir/outputs/aar/euclideanOperationsLib-debug.aar&quot;<br><br>            // Add dependencies to the POM<br>            pom.withXml {<br>                def dependencies = asNode().appendNode(&#39;dependencies&#39;)<br>                configurations.getByName(&quot;releaseCompileClasspath&quot;).getResolvedConfiguration().getFirstLevelModuleDependencies().each {<br>                    def dependency = dependencies.appendNode(&#39;dependency&#39;)<br>                    dependency.appendNode(&#39;groupId&#39;, it.moduleGroup)<br>                    dependency.appendNode(&#39;artifactId&#39;, it.moduleName)<br>                    dependency.appendNode(&#39;version&#39;, it.moduleVersion)<br>                }<br>            }<br>        }<br>    }<br>    repositories {<br>        // Configure the repository to which the artifacts will be published<br>        maven {<br>            // Replace example with your domain name and project_id with your project id <br>            url &quot;https://gitlab.example.com/api/v4/projects/&lt;project_id&gt;/packages/maven&quot;<br>            name &quot;GitLab&quot;<br>            credentials(HttpHeaderCredentials) {<br>                // Use the Deploy token for authentication<br>                name = &quot;Deploy-Token&quot;<br>                value = &quot;&lt;your gitLab Deploy Token&gt;&quot;<br>            }<br>            authentication {<br>                header(HttpHeaderAuthentication)<br>            }<br>        }<br>    }<br>}</pre><p>Don’t forget to add it in the Gradle configuration of our library module:</p><pre>// Apply the &quot;gradle-mvn-push.gradle&quot; script<br>apply from: &quot;$rootDir/gradle-mvn-push.gradle&quot;</pre><p>ow we are ready to publish this library. Let’s execute this command:</p><pre>./gradlew publish</pre><p>And ta-da! We have our module published in the GitLab registry of our project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPla_CCk9z8Qb7JojA2zOQ.png" /><figcaption>Package published</figcaption></figure><h4>3. Set Up GitLab CI/CD Pipeline</h4><p>To automate the build and publish process for our library, we’ll use a GitLab CI/CD pipeline. Let’s create a .gitlab-ci.yml file with the following content:</p><pre>default:<br>  image: ghcr.io/cirruslabs/android-sdk:34<br><br>stages:<br>  - buildandpublish<br><br>build_and_publish_library:<br>  stage: buildandpublish<br>  script:<br>    - ./gradlew build<br>    - ./gradlew publish<br>  only:<br>    - master</pre><p>Now, let’s push our code to GitLab and see if the pipeline succeeds:</p><pre>git init<br>git add *<br>git commit -am &quot;Init project&quot; <br>git remote add origin git@gitlab.com:sihemBouh/euclideanoperations.git<br>git push origin master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ApcUuefHiIxx1NgmFEcIow.png" /></figure><p>At this stage, we can use the CI Job token instead of the Deploy token that we created before. Let’s make a small change in the gradle-mvn-push.gradle file:</p><pre><br>...<br>credentials(HttpHeaderCredentials) {<br>  name = &quot;Job-Token&quot;<br>  value = System.getenv(&quot;CI_JOB_TOKEN&quot;)<br>}<br>...</pre><p>By making this change, the CI/CD pipeline will use the GitLab CI job token to authenticate and push the library to the GitLab Maven registry.</p><p>With these steps, your CI/CD pipeline is set up to automatically build and publish your Android library to the GitLab registry whenever you push changes to the master branch.</p><h4>4. How to use library in other projects</h4><p>Once your Android library is published to the GitLab Maven registry, you can easily integrate it into other projects.</p><p>First, in a new android project you need to add the GitLab Maven repository to build.gradle file (at the project level):</p><pre>allprojects {<br>    repositories {<br>        google()<br>        mavenCentral()<br>        maven {<br>            // Replace example with your domain name and project_id with your project id<br>            url &quot;https://gitlab.example.com/api/v4/projects/&lt;project_id&gt;/packages/maven&quot;<br>            credentials(HttpHeaderCredentials) {<br>                name = &quot;Deploy-Token&quot;<br>                value = &quot;&lt;your gitLab Deploy Token&gt;&quot;<br>            }<br>            authentication {<br>                header(HttpHeaderAuthentication)<br>            }<br>        }<br>    }<br>}</pre><p>Next, add the library dependency to your module’s build.gradle file:</p><pre>dependencies {<br>    implementation &quot;com.example.euclideanoperationslib:euclideanOperationsLib:1.0.0&quot;<br>}</pre><p>Now you can use the library in your code. For example, if you want to use the addOp function from the library, you can do it like this:</p><pre>import androidx.appcompat.app.AppCompatActivity<br>import android.os.Bundle<br>import android.util.Log<br>import com.example.euclideanoperationslib.addOp<br><br>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.activity_main)<br><br>        // Use the library function<br>        Log.i(&quot;TEST&quot;, &quot;Result of addOp: ${addOp(1, 2)}&quot;)<br>    }<br>}</pre><p>If everything is set up correctly, you will see the output from the library’s function in your logcat.</p><p>Congratulations! You have successfully created, configured, and published an Android library to the GitLab Maven registry. You have also set up a CI/CD pipeline to automate the build and publish process and learned how to integrate and use your library in other projects. By following this tutorial, you can now share reusable components within your team and across multiple projects efficiently, enhancing collaboration and productivity. Happy coding!</p><p>Please, do not hesitate to leave a comment below if you have any questions or remarks.</p><ul><li>Link to GitLab project</li></ul><p><a href="https://gitlab.com/sihemBouh/euclideanoperations">bouhenniche sihem / EuclideanOperations · GitLab</a></p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ac34563ae40" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/publish-your-android-library-to-gitlab-registry-with-ci-cd-pipeline-7ac34563ae40">Publish Your Android Library to GitLab Registry with CI/CD Pipeline</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create VueJS based Chrome extension ?]]></title>
            <link>https://javascript.plainenglish.io/how-to-create-vuejs-based-chrome-extension-645d6fe9bf53?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/645d6fe9bf53</guid>
            <category><![CDATA[laravel-mix]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Tue, 30 May 2023 09:08:40 GMT</pubDate>
            <atom:updated>2024-08-22T05:14:20.451Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Create a Vue-based Chrome Extension</h3><h4>Build Vue.js Chrome extension from scratch using Webpack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2FeTrTKKCQjZNFwxfqkbQ.jpeg" /></figure><p>Google Chrome is the most popular internet browser in the world with a global market share of <a href="https://gs.statcounter.com/browser-market-share">65.84</a>%, thanks to various factors. One of the most significant factors is the extensive library of Chrome extensions. These small software programs are designed to enhance and customize the browsing experience for users, offering additional features and tools to improve productivity and convenience.</p><p>In this tutorial, we will create a chrome extension that displays a random quote using <strong>VueJS</strong> and <strong>Webpack</strong> from scratch without any extension boilerplate.</p><h4>About the example</h4><p>The extension that we will create is very simple, it will :</p><ul><li>Fetch a random quote from : <a href="https://zenquotes.io/">https://zenquotes.io/</a></li><li>Display the quote in a popup.</li></ul><h4>What we will use ?</h4><ul><li><a href="https://vuejs.org/">VueJS :</a> a very popular JavaScript framework for creating web applications.</li><li>W<a href="https://webpack.js.org/">ebpack</a>: a powerful module bundler that prepares JavaScript and assets for the browser.</li><li><a href="https://laravel-mix.com/">LaravelMix</a>: a thin layer on top of Webpack. It exposes a simple, fluent API for dynamically constructing your Webpack configuration.</li></ul><h4>Todo list</h4><ol><li>Create project and install dependencies</li><li>Create project structure</li><li>Code the logic of the extension</li><li>Setup Webpack and LaravelMix configurations</li><li>Build and test the extension</li></ol><blockquote><em>💡</em> <strong>Learn how to use Pinia for state management in Vue.js:</strong></blockquote><p><a href="https://differ.blog/p/a-comprehensive-guide-to-vue-js-state-management-using-pinia-207096">A Comprehensive Guide to Vue.js State Management using Pinia</a></p><blockquote><em>👉</em> To read more such acrticles, <a href="https://differ.blog/"><strong>sign up for free on Differ</strong></a>.</blockquote><h3>Create project and install dependencies</h3><p>The very first step is to create our NodeJS project.</p><p>So let’s create a folder named RandomQuote and initialize it as a NodeJS project:</p><pre>mkdir RandomQuote<br>cd RandomQuote<br>npm init</pre><p>This command will ask us a couple of questions to create the package.json file which is the manifest for our project containing some metadata such as project name, version, dependencies …</p><pre>{<br>  &quot;name&quot;: &quot;random-quote&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;Browser extension that fetch a random quote from zenquotes.io&quot;,<br>  &quot;scripts&quot;: {},<br>  &quot;repository&quot;: {<br>    &quot;type&quot;: &quot;git&quot;,<br>    &quot;url&quot;: &quot;git+https://github.com/EmployeeSatisfactionSurvey/RandomQuote.git&quot;<br>  },<br>  &quot;keywords&quot;: [<br>    &quot;browser&quot;,<br>    &quot;webpack&quot;,<br>    &quot;laravel-mix&quot;,<br>    &quot;extension&quot;<br>  ],<br>  &quot;author&quot;: &quot;Sihem BOUHENNICHE&quot;,<br>  &quot;bugs&quot;: {<br>    &quot;url&quot;: &quot;https://github.com/EmployeeSatisfactionSurvey/RandomQuote/issues&quot;<br>  },<br>  &quot;homepage&quot;: &quot;https://github.com/EmployeeSatisfactionSurvey/RandomQuote#readme&quot;<br>}</pre><p>Then, we install some development dependencies that will help us to build our extension :</p><ul><li>LaravelMix and cross-env packages. cross-env allows us to set environment variables in a cross-platform way.</li></ul><pre>npm install laravel-mix cross-env</pre><ul><li>VueJS and the necessary packages to build our VueJS project. we install VueJS loaders, which are essential for loading and compiling VueJS single-file components. We also include style transformers to compile and load the styles associated with our components.</li></ul><pre>npm i vue vue-loader vue-template-compiler postcss sass sass-loader</pre><h3>Create project structure</h3><p>Prior to diving into coding, it is important to consider the project structure. Therefore, I recommend creating two folders:</p><ul><li>/src : contains all the project resources including the source code, styles and images.</li><li>/dist : designated for the production environment. Initially, it contains only two files, manifest.json and popup.html . However, once the project is built, additional files such as bundles and image resources will be automatically added to this folder.</li></ul><p>Let’s take a deeper look at the content of /dist folder :</p><ul><li>popup.html : Contains the entry point for our HTML document (here we talk about the popup component). It provides a placeholder for our VueJS application.</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en_US&quot;&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Random Quote&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/popup.css&quot; /&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;div id=&quot;app&quot;&gt;&lt;/div&gt;<br>    &lt;script src=&quot;js/popup.js&quot;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>manifest.json : Contains important metadata and configuration details about the extension.</li></ul><pre>{<br>  &quot;manifest_version&quot;: 3,<br>  &quot;name&quot;: &quot;Random Quote&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;Browser extension that fetch a random quote from zenquotes.io&quot;,<br>  &quot;host_permissions&quot;: [&quot;https://zenquotes.io/&quot;],<br>  &quot;action&quot;: {<br>    &quot;default_popup&quot;: &quot;popup.html&quot;,<br>    &quot;default_icon&quot;: {<br>      &quot;16&quot;: &quot;images/logo-16x16.png&quot;,<br>      &quot;48&quot;: &quot;images/logo-48x48.png&quot;,<br>      &quot;192&quot;: &quot;images/logo-192x192.png&quot;<br>    }<br>  }<br>}</pre><h3>Code the logic of the extension</h3><p>Now, it’s time to dive into coding the logic of the extension. We start by creating three folders in /src folder :</p><ul><li>/js : Contains VueJS components. Inside it we create two files popup.js and popup.vue</li></ul><pre>import { createApp } from &quot;vue&quot;;<br>import Popup from &quot;./Popup.vue&quot;;<br>createApp(Popup).mount(&quot;#app&quot;);</pre><p>For the Popup.vue file it contains the declaration of our popup component. Here I’ve created a logic to fetch a random quote and display it in a popup.</p><pre>&lt;template&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    &lt;h1 class=&quot;title text-center&quot;&gt;Random Quote&lt;/h1&gt;<br>    &lt;blockquote class=&quot;quote-card&quot;&gt;<br>      &lt;p&gt;<br>        {{ state.quote }}<br>      &lt;/p&gt;<br><br>      &lt;cite&gt; {{ state.author }} &lt;/cite&gt;<br>    &lt;/blockquote&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br>&lt;script&gt;<br>export default {<br>  data() {<br>    return {<br>      state: {<br>        quote: &quot;&quot;,<br>        author: &quot;&quot;,<br>      },<br>    };<br>  },<br>  async created() {<br>    try {<br>      const response = await fetch(&quot;https://zenquotes.io/api/random&quot;);<br>      const data = await response.json();<br><br>      if (Array.isArray(data) &amp;&amp; data.length &gt; 0) {<br>        this.state.quote = data[0].q; // Extract the quote from the response<br>        this.state.author = data[0].a;<br>      } else {<br>        this.state.quote = &quot;Failed to fetch quote.&quot;;<br>      }<br>    } catch (error) {<br>      console.error(error);<br>      this.state.quote = &quot;Error occurred while fetching quote.&quot;;<br>    }<br>  },<br>};<br>&lt;/script&gt;</pre><ul><li>/images : Contains all the images of the project</li><li>/sass : Contains components styles (Styles copied from <a href="https://codepen.io/bharanim/pen/BoLNdd">https://codepen.io/bharanim/pen/BoLNdd</a> )</li></ul><pre>.container {<br>  width: 500px;<br>}<br><br>@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,200italic);<br><br>$background: #eee;<br>$black: #222222;<br>$white: #ffffff;<br><br>$default: #fff;<br>$defaultTextColor: #222222;<br>$defaultSecondaryTextColor: #eee;<br><br>.container {<br>  max-width: 800px;<br>  font-family: &quot;Source Sans Pro&quot;, sans-serif;<br>  font-weight: 300;<br>}<br><br>.text-center {<br>  text-align: center;<br>}<br><br>.quote-card {<br>  background: $default;<br>  color: $defaultTextColor;<br><br>  padding: 20px;<br>  padding-left: 50px;<br>  box-sizing: border-box;<br>  box-shadow: 0 2px 4px rgba($black, 0.12);<br><br>  position: relative;<br>  overflow: hidden;<br>  min-height: 120px;<br><br>  p {<br>    font-size: 22px;<br>    line-height: 1.5;<br>    margin: 0;<br>    max-width: 80%;<br>  }<br><br>  cite {<br>    font-size: 16px;<br>    margin-top: 10px;<br>    display: block;<br>    font-weight: 200;<br>    opacity: 0.8;<br>  }<br><br>  &amp;:before {<br>    font-family: Georgia, serif;<br>    content: &quot;\201C&quot;;<br>    position: absolute;<br>    top: 10px;<br>    left: 10px;<br>    font-size: 5em;<br>    color: rgba($defaultSecondaryTextColor, 0.8);<br>    font-weight: normal;<br>  }<br><br>  &amp;:after {<br>    font-family: Georgia, serif;<br>    content: &quot;\201D&quot;;<br>    position: absolute;<br>    bottom: -50%;<br>    line-height: 100px;<br>    right: 0!important;<br>    font-size: 25em;<br>    color: rgba($defaultSecondaryTextColor, 0.8);<br>    font-weight: normal;<br>  }<br><br>  @media (max-width: 640px) {<br>    &amp;:after {<br>      font-size: 22em;<br>      right: -25px;<br>    }<br>  }<br>}</pre><h3>Setup Webpack and LaravelMix configurations</h3><p>At this stage, we need to create a configuration file responsible for building and compiling our VueJS code and styles.</p><p>To begin, we create a file named webpack.mix.js. Within this file, we include the necessary instructions to perform various tasks.</p><ol><li>The laravel-mix package is imported to simplify the build process.</li><li>The public path for the compiled assets is set to the root directory.</li><li>The sass method is used to compile the popup.scss file from the src/sass directory, saving the resulting CSS to the dist/css directory.</li><li>The js method processes the popup.js file from the src/js directory, saving the compiled JavaScript to the dist/js directory.</li><li>The vue method is applied to handle compilation of VueJS single-file components.</li><li>The copy method copies all files and folders from the src/images directory to the dist/images directory, ensuring the availability of images in the production build.</li></ol><pre>let mix = require(&quot;laravel-mix&quot;);<br><br>mix<br>  .setPublicPath(&quot;./&quot;)<br>  .sass(&quot;src/sass/popup.scss&quot;, &quot;dist/css&quot;)<br>  .js(&quot;src/js/popup.js&quot;, &quot;dist/js&quot;)<br>  .vue()<br>  .copy(&quot;src/images/&quot;, &quot;dist/images&quot;)<br>  .options({<br>    processCssUrls: false,<br>  });</pre><p>Then, we create mix-manifest.json file which is file is used to help manage asset versioning and cache-busting.</p><pre>{<br>    &quot;/dist/js/popup.js&quot;: &quot;/dist/js/popup.js&quot;,<br>    &quot;/dist/css/popup.css&quot;: &quot;/dist/css/popup.css&quot;,<br>    &quot;/dist/images/logo-192x192.png&quot;: &quot;/dist/images/logo-192x192.png&quot;,<br>    &quot;/dist/images/logo-16x16.png&quot;: &quot;/dist/images/logo-16x16.png&quot;,<br>    &quot;/dist/images/logo-48x48.png&quot;: &quot;/dist/images/logo-48x48.png&quot;,<br>    &quot;/dist/images/logo.png&quot;: &quot;/dist/images/logo.png&quot;<br>}</pre><p>Finally, we add script command to package.json file which will be responsible of compiling code and generating production release.</p><pre>{<br>...<br>&quot;scripts&quot;: {<br>    &quot;production&quot;: &quot;cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --env=production --config=node_modules/laravel-mix/setup/webpack.config.js&quot;,<br>    &quot;prod&quot;: &quot;npm run production&quot;<br> },<br>...<br>}</pre><h3>Build and test the extension</h3><p>To finalize the process, we compile our code and build the dist folder by executing the following command:</p><pre>npm run prod</pre><p>After that, follow these steps to see the final result :</p><ol><li>Open the Chrome browser.</li><li>In the address bar, type in “chrome://extensions/” and press Enter. This will take you to the Extensions page.</li><li>Enable development mode by toggling the switch located at the top-right corner of the Extensions page.</li><li>Once development mode is enabled, you will see a new toolbar with additional options.</li><li>Click on the “Load unpacked” button, usually located at the top-left or top-center of the Extensions page.</li><li>A file explorer window will open. Navigate to the folder or directory where you have stored the release files of your extension.</li><li>Select the folder containing the extension release files and click the “Select” or “Open” button.</li><li>Chrome will now load and install the extension from the selected folder.</li><li>Once the installation is complete, you will see the extension added to the list of installed extensions on the Extensions page.</li></ol><p>Our extension looks like that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*cUzBwtDguwcEKPNEozeEjg.png" /></figure><h3>Conclusion</h3><p>In conclusion, this tutorial has provided a step-by-step guide on creating a VueJS based Chrome extension from scratch using webpack and LaravelMix.</p><p>Thank you for reading.</p><p>Please, do not hesitate to leave a comment below if you have any questions or remarks.</p><ul><li>Link to GitHub project</li></ul><p><a href="https://github.com/SihemBouhenniche/random-daily-quote">GitHub - SihemBouhenniche/random-daily-quote</a></p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=645d6fe9bf53" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/how-to-create-vuejs-based-chrome-extension-645d6fe9bf53">How to create VueJS based Chrome extension ?</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is it possible to create a REST API with NuxtJS ?]]></title>
            <link>https://javascript.plainenglish.io/is-it-possible-to-create-a-rest-api-with-nuxtjs-230685fbd2bc?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/230685fbd2bc</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 20:37:22 GMT</pubDate>
            <atom:updated>2024-09-12T17:22:59.285Z</atom:updated>
            <content:encoded><![CDATA[<h3>Is it Possible to Create a REST API with Nuxt?</h3><h4>Create Express + MongoDB RESTful API using serverMiddleware in Nuxt app using docker-compose</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ni7m2h3hY8id4AMkj59pbQ.png" /></figure><p>After I started using NuxtJS last year, I discovered how much this framework is powerful and full of options and properties that made creating web apps much easier. The most important thing that you need to know about this framework is that NuxtJS supports SSR (server side rendering), which means that NuxtJS requires a server that renders a webpage and passes it to the VueJS client-side (all that is implemented by NuxtJS behind scenes). However, if you try to implement complicated operations like accessing to a database or having push notifications channels you will find difficulties specially if you try to do it without requesting external REST API. This pushes us to ask the question :</p><p><strong><em>Is it possible to create a REST API with NuxtJS ?</em></strong></p><p>The answer is : <strong>YES. </strong>By using the <a href="https://nuxtjs.org/docs/configuration-glossary/configuration-servermiddleware/">serverMiddleware</a> property of NuxtJS, creating a REST API with NuxtJS is totally possible. Through this tutorial, we will discover how to achieve that.</p><blockquote><em>💡</em> <strong>Also learn how to master Tailwind integration with Nuxt.js:</strong></blockquote><p><a href="https://differ.blog/p/mastering-tailwind-css-integration-with-popular-javascript-frameworks-in-2024-6ab6b1#heading-13">Mastering Tailwind CSS Integration with Popular JavaScript Frameworks in 2024</a></p><blockquote><em>👉</em> To read more such articles, <a href="https://differ.blog/"><strong>sign up for free on Differ</strong></a>.</blockquote><h3>Todo list</h3><ol><li>Create Nuxt app</li><li>Setup serverMiddleware</li><li>Create ExpressJS API</li><li>Dockerize our Nuxt APP</li><li>Establish connection with database</li></ol><h3>About the example</h3><p>The project that we will create is a simple TO DO application with some basic CRUD operations.</p><h3>What we will use ?</h3><ul><li><a href="https://nuxtjs.org/">NuxtJS :</a> is an open source framework based on VueJS and NodeJS to simplify creating SSR web applications using VueJS.</li><li><a href="https://expressjs.com/">ExpressJS</a> : is a minimal Node.js web application framework that provides a set of features for web and mobile applications.</li><li><a href="https://www.mongodb.com/">MongoDB :</a> is a document-oriented database. Classified as a No SQL database. MongoDB uses JSON-like documents with optional schemas.</li><li><a href="https://www.docker.com/">Docker</a> &amp; <a href="https://docs.docker.com/compose/gettingstarted/">docker-compose</a> : is an open platform for developing, shipping, and running applications.</li></ul><h3>1 . Create Nuxt app</h3><p>The very first step in our project is to create a NuxtJS app, we will use <a href="https://nuxtjs.org/docs/get-started/installation">create-nuxt-app </a>webpack to get started quickly.</p><pre>$ npm init nuxt-app &lt;project-name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*ezN6vbXN2_QljMdSNiqmrw.png" /><figcaption>Create nuxt app</figcaption></figure><p>Since we want to focus on the API part, i will suggest to you to clone directly the Front-end part that I’ve created for this purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeFfe25DeE2dUrGB6urlAw.png" /><figcaption>UI for our todo app</figcaption></figure><h3>2 . Setup serverMiddleware</h3><p>According to the official documentation of NuxtJS, the serverMiddleware property helps us to define a server-side middleware.</p><blockquote>Nuxt internally creates a <a href="https://github.com/senchalabs/connect">connect </a>instance that you can add your own custom middleware to. This allows us to register additional routes (typically /api routes) <strong>without need for an external server</strong>.</blockquote><p>So let’s create a folder named api at the root of our project, and create inside it a file named index.js</p><p>To start, our file contains just a logger middleware :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b20a2488ee6b203a15bd9c9c7f85233f/href">https://medium.com/media/b20a2488ee6b203a15bd9c9c7f85233f/href</a></iframe><p>Then we should tell our NuxtJS app to consider our middelware, for that let’s add this property to nuxt.config.js file :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5597366543f9468d21e7fdd3f78ce90/href">https://medium.com/media/b5597366543f9468d21e7fdd3f78ce90/href</a></iframe><p>If you try to enter to any page in our NuxtJS app and see in your console, you will find the URL that you’ve requested. In fact, every page visit will handle our logger middleware.</p><h3>3. Create ExpressJS API</h3><p>Now, let’s create the API part. We will start by installing ExpressJS.</p><pre>$ npm install express --save</pre><p>Then let’s update the content of our api/index.js to be like that :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6bd2aacefa2d9f244817b9a0a97aefb/href">https://medium.com/media/e6bd2aacefa2d9f244817b9a0a97aefb/href</a></iframe><p>Now if you try to request <a href="http://localhost:3000/api">http://localhost:3000/api</a> you will get the following result :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upehkj4mrXtyu35nyxt6aw.png" /></figure><h3>4 . Dockerize our Nuxt APP</h3><p>For development purpose, we will use Docker and docker-compose to build and run our application. By using Docker we can setup easily a local development environment. On the other side, using docker-compose helps us to build and run more than one container. In our case we will need two containers :</p><ul><li>Container for our Nuxt application</li><li>Container for our MongoDB database</li></ul><p>The architecture of our application is shown in the diagram below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*LkvDL9chJ9QUg7yRD_SSGg.png" /><figcaption>Application architecture</figcaption></figure><p>Let’s start by creating Dockerfile at the root of our project with the following content :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7aff4ea1e8f72b0056f5cd0ddc6754f/href">https://medium.com/media/f7aff4ea1e8f72b0056f5cd0ddc6754f/href</a></iframe><p>After that, we will made some modifications in our nuxt.config.js file :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8620502239af289c1d13ef1e7c130b9/href">https://medium.com/media/b8620502239af289c1d13ef1e7c130b9/href</a></iframe><p>Now, we will create a docker-compose.yaml file in which we will define our two containers :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb4e98e2c28f1f15ce387be28374feb4/href">https://medium.com/media/eb4e98e2c28f1f15ce387be28374feb4/href</a></iframe><p>Just one step and we can build and run our application by docker. So, let’s define .env files for database and for the Nuxt app :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d7e8251dbc87c91feab2ae78798acaa/href">https://medium.com/media/0d7e8251dbc87c91feab2ae78798acaa/href</a></iframe><p>And for database/.env :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8efff5cd0a81b3e0b61c24ca9441b4ab/href">https://medium.com/media/8efff5cd0a81b3e0b61c24ca9441b4ab/href</a></iframe><p>In addition to that, we can also set admin user for our todo_db` , for that we should create a mongo-init.js` file inside database` folder :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ff8cb2c14b74ca99eda16dae943ced4/href">https://medium.com/media/2ff8cb2c14b74ca99eda16dae943ced4/href</a></iframe><p>Now, we can build and run our app by typing :</p><pre>$ docker-compose up --build</pre><h3>5. Establish connection with database</h3><p>In this tutorial we will use MongoDB database. In fact, the combination ExpressJS and MongoDB is very popular, but you have any preference for any other database you can achieve that with same process.</p><p>For that, we will use <a href="https://mongoosejs.com/">mongoose</a> which is a MongoDB object modeling for Node.js. Let’s then install mongoose :</p><pre>$ npm install mongoose --save</pre><p>And create the following file structure :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*5DwCdQavuH-0G5ORcSUBTA.png" /></figure><p>Let’s explain content of every file :</p><ul><li>todo.model.js contains our todo schema :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed18a98590cabefe204f6553467c5ff9/href">https://medium.com/media/ed18a98590cabefe204f6553467c5ff9/href</a></iframe><ul><li>todo.controller.js contains our CRUD operations :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d02fb701766ebde3fa98f5d5c38bc54/href">https://medium.com/media/9d02fb701766ebde3fa98f5d5c38bc54/href</a></iframe><ul><li>todo.routes.js contains our routes description :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e6e5479908e6b1405f0da44bcdc227a/href">https://medium.com/media/0e6e5479908e6b1405f0da44bcdc227a/href</a></iframe><ul><li>Finally, database.js contains connection with our database. The content of this file is :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a69358299031129fbaccb08e7dabeb7e/href">https://medium.com/media/a69358299031129fbaccb08e7dabeb7e/href</a></iframe><p>At the end let’s update our index.js file to consider our changes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ceae6eac6e41098f76ac0465e3880dd7/href">https://medium.com/media/ceae6eac6e41098f76ac0465e3880dd7/href</a></iframe><p>Now, you can test every endpoint of our API by using Postman for example.</p><h3>Conclusion</h3><p>We arrived at the end of this tutorial, thank you for reading.</p><p>Please, do not hesitate to leave a comment below if you have any questions or remarks.</p><ul><li>Link to GitHub project :</li></ul><p><a href="https://github.com/SihemBouhenniche/Todo-App-Nuxt">GitHub - SihemBouhenniche/Todo-App-Nuxt: Todo app using NuxtJS - ExpressJS - MongoDB and Docker-compose</a></p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://twitter.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a></li><li>Visit our other platforms: <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=230685fbd2bc" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/is-it-possible-to-create-a-rest-api-with-nuxtjs-230685fbd2bc">Is it possible to create a REST API with NuxtJS ?</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Your First NPM Package and Publish It into the Gitlab Registry]]></title>
            <link>https://javascript.plainenglish.io/create-your-first-npm-package-and-publish-it-into-gitlab-registry-94eec41e0770?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/94eec41e0770</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Fri, 14 Oct 2022 12:52:23 GMT</pubDate>
            <atom:updated>2022-11-04T02:04:14.346Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to create your own npm package that includes and assembles a set of methods that you want to reuse across multiple projects</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*-kwgrTjV1caKyGGu0a5-_A.png" /></figure><p>While using NodeJS to develop your web apps, you may notice the existence of a variety of NPM packages and libraries that makes the development process much easier. These packages help us reduce project complexity and allow us to reuse open source methods without a without hassle.</p><p>So, If you’ve ever wondered how to create your own npm package that includes and assembles a set of methods that you want to reuse across multiple projects, you are in the right place!</p><h3>Todo list</h3><ol><li>Create the npm package 🎉</li><li>Setup unit tests (optional) ✅</li><li>Setup documentation generation (optional) 📝</li><li>Create / configure Gitlab repository for publishing the NPM package 🔧</li><li>Setup .gitlab-ci pipeline 👷</li><li>Push and publish our npm package 🚀 !!</li><li>How to install our project in other projects ? ➕</li></ol><h4>About the example</h4><p>The package that we will create offers some basic mathematical operations about calculating surface areas of the most common geometric shapes : triangles, squares, rectangles and circles.</p><h3>🎉 Create the npm package</h3><h4>a . Initialize the project</h4><p>The very first step is to create the npm project and make it working locally. So let’s start by creating a folder named sb-geometry-plugin . Then, initialize it :</p><pre># Create package.json file<br>$ npm init</pre><p>This will ask us to fill some information (see the picture below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*NEkhOvUOqE_BMikI4Q2nQw.jpeg" /><figcaption>Initialize package</figcaption></figure><h4>b. Install devDependencies</h4><p>Then, we should install some required and optional development dependencies that will help us to build the package easily. For that we need :</p><ul><li><strong>webpack</strong> which is a module bundler and <strong>webpack-cli</strong> which is a command-line tool that uses webpack. By using webpack we should also use babel-loader to transpile our ES6 code to ES5 before bundling.</li></ul><pre>$ npm i --save-dev webpack webpack-cli <a href="http://twitter.com/babel/core">@babel/core</a> babel-loader</pre><ul><li><strong>jest</strong> for writing jest test-cases (optional).</li></ul><pre>$ npm i --save-dev jest</pre><ul><li><strong>prettier</strong> , <strong>eslint-plugin-prettier</strong> and <strong>eslint-config-prettier</strong> for linting and formatting our code (optional).</li></ul><pre>$ npm i --save-dev prettier eslint-plugin-prettier eslint-config-prettier</pre><ul><li><strong>documentation</strong> for generating documentation automatically (optional).</li></ul><pre>$ npm i --save-dev documentation</pre><h4>c. Initialize git repository</h4><p>Now we should initialize our git repository and add <em>.gitignore</em> file with the following content :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d22e021ceaca05c643a60773b61a13bd/href">https://medium.com/media/d22e021ceaca05c643a60773b61a13bd/href</a></iframe><pre>$ git init<br>$ git add *<br>$ git commit -am &quot;Initialize project&quot;</pre><h4>d. Start coding</h4><p>The initial structure of our project is shown in the picture below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*ODQ4LEttKjhYf7nX24nPvw.png" /></figure><p>As you can see in the picture, our project contains a bunch of files and folders. Now let’s explain what’s the content of each one and what’s used for.</p><ul><li><strong>.eslintigonre</strong> /<strong>.eslintrc.json</strong> / <strong>.prettierogonre</strong> / <strong>.prettierrc.js</strong> : These files are used to setup Prettier + ESLint. Prettier is used to auto-format our code to enforce an opinionated code format, ESLint makes sure to keep our code style in a good form.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a9300c19ea27d716dbd4c4fa8fc6935/href">https://medium.com/media/6a9300c19ea27d716dbd4c4fa8fc6935/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7075f83e3be9c34f213ca258156d976f/href">https://medium.com/media/7075f83e3be9c34f213ca258156d976f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe37f2cefde7c68ec0cbe671b82629ef/href">https://medium.com/media/fe37f2cefde7c68ec0cbe671b82629ef/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61969f525727252f9959b0236ff94239/href">https://medium.com/media/61969f525727252f9959b0236ff94239/href</a></iframe><ul><li><strong>webpack.config.js</strong> : Webpack configuration file that define how to bundle our JavaScript code and prepare it for production.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/786666574bd155a16431aea72520615b/href">https://medium.com/media/786666574bd155a16431aea72520615b/href</a></iframe><ul><li><strong>/src/methods</strong> : Contains 3 files, each one exports a formula for calculating a specific geometric shape area.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65846e6f453700fa4c88ba21b5fc8308/href">https://medium.com/media/65846e6f453700fa4c88ba21b5fc8308/href</a></iframe><ul><li><strong>index.js</strong> : The entry point of the package, it exports our utilities methods.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55428e118771d3cbcec9816046f93e5c/href">https://medium.com/media/55428e118771d3cbcec9816046f93e5c/href</a></iframe><h3>✅ Setup unit tests (Optional)</h3><p>We will use Jest framework for writing unit tests of our 3 methods. For that let’s create /tests folder and start writing our test cases :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23c227e96f898fab8ec485b1340bfadf/href">https://medium.com/media/23c227e96f898fab8ec485b1340bfadf/href</a></iframe><p>Before running tests, we should configure unit tests in package.json file :</p><pre>...<br>&quot;scripts&quot; : {</pre><pre>       &quot;test&quot;: &quot;jest --coverage --passWithNoTests&quot; // Run tests<br>},<br>&quot;jest&quot;: { // jest configuration</pre><pre>       &quot;verbose&quot;: true,</pre><pre>       &quot;testEnvironment&quot;: &quot;node&quot;<br>}</pre><pre>...</pre><p>After that, we can run our tests and get coverage report inside /coverage:</p><pre>$ npm run test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ileW6yHEl12DbOLyd7Jl4Q.png" /><figcaption>Output of running unit tests</figcaption></figure><h3>📝 Setup documentation generation (optional)</h3><p>By using documentation tool we can generate automatically code documentation from jsDoc annotations that we’ve included in our code.</p><p>So let’s add some scripts to our package.json file :</p><pre>.....<br>&quot;scripts&quot;: {</pre><pre>    &quot;docs:clean&quot;: &quot;rimraf docs&quot;, <strong>// Delete /docs folder</strong></pre><pre>    &quot;docs:build&quot;: &quot;npm run docs:clean &amp;&amp; documentation build src/**           -f html -o docs&quot;, <strong>// Build documentation</strong></pre><pre>     &quot;clean&quot;: &quot;rimraf dist&quot;, <strong>// Delete /dist folder</strong></pre><pre>     &quot;build&quot;: &quot;npm run clean &amp;&amp; webpack --mode production&quot;, <strong>// Build project</strong></pre><pre>     &quot;prepare&quot;: &quot;npm run build &amp;&amp; npm run docs:build&quot;, <strong>// Prepare project for production</strong></pre><pre>     &quot;test&quot;: &quot;jest --coverage --passWithNoTests&quot; <strong>// Run tests</strong></pre><pre>},</pre><pre>.....</pre><p>Now we can easily test, build and generate documentation of our project just by running the correspondent script. For example, for building the package and preparing it to production, we just run :</p><pre>$ npm run prepare</pre><p>This will generate two folders :</p><ul><li><strong>/dist</strong> : the distribution version of the code</li><li><strong>/docs : </strong>contains code documentation</li></ul><h3>🔧 Create Gitlab repository</h3><p>First of all, we start by creating a blank Gitlab project named “sb-geometry-plugin”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*XLB0FszpDN3BSpu5uTjlUw.jpeg" /></figure><p>Then we push our code.</p><pre>$ git remote add origin <a href="/service/mailto:git@gitlab.com">git@gitlab.com</a>:xxxxxxx/sb-geometry-plugin.git<br>$ git push --set-upstream origin master</pre><h3>👷 Setup .gitlab-ci pipeline</h3><p>Now, we will use Gitlab CI/CD tool for managing our workflow. According to the official documentation, GitLab CI/CD is a tool for software development using the continuous methodologies.</p><p>By using GitLab CI/CD we can define a pipeline for building and testing our project, for more information about how it works, you can look at <a href="https://docs.gitlab.com/ee/ci/introduction/index.html">the official documentation.</a></p><p>So, let’s create a file named .gitlab-ci.yml with the following content :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a55187b468532e06e2f7310f6c46af37/href">https://medium.com/media/a55187b468532e06e2f7310f6c46af37/href</a></iframe><p>Our pipeline contains 4 stages, each one is responsible of doing one task .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*FtDocko1cJhqUjAgTOH5Iw.jpeg" /></figure><h3>🚀 Push and publish our npm package !!</h3><p>If you try now to push our code directly you see that Gitlab detects directly our pipeline and starts to run it ( look at the picture below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIjtR5gzuhRl9YNtveODLA.png" /></figure><p>Oops, our pipeline fails when he tries to publish a new package <strong>😭. </strong>But why ??</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B3cw6_sVDgq_8ZpzDz_0gA.png" /></figure><p>Don’t panic, it’s totally normal. In fact, our project needs more configuration to access the Gitlab registry.</p><h4>a. Semantic-release</h4><p>The first thing that we will do is to use a great tool called semantic-release, this tool helps us to manage when we should release a new version according to Git commits, for more information look at <a href="https://docs.gitlab.com/ee/ci/examples/semantic-release.html">this</a>.</p><p>So let’s install it :</p><pre>$ npm install semantic-release @semantic-release/git @semantic-release/gitlab @semantic-release/npm --save-dev</pre><p>After installing required packages, we need to configure semantic-release by using a config file named .releaserc.json</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0354b066d46266c123d8f4d24b21132/href">https://medium.com/media/c0354b066d46266c123d8f4d24b21132/href</a></iframe><p>Then let’s update our package.json file by :</p><ol><li>Renaming the project to be : @your_scope/project_name</li><li>Changing main file to be : &quot;main&quot;: &quot;dist/index.js&quot;</li><li>Adding new script : &quot;semantic-release&quot;: &quot;semantic-release&quot;</li><li>Adding publishConfig entry :</li></ol><pre>&quot;publishConfig&quot;: {</pre><pre>&quot;@your_scope:registry&quot;: &quot;https://gitlab.com/api/v4/projects/40114401/packages/npm/&quot;</pre><pre>},</pre><h4>b. Create .npmrc file</h4><blockquote>npm gets its config settings from the command line, environment variables, and npmrc files</blockquote><p>To install a package from a external registry (in our case Gitlab) we need to tell npm from where you should install our package. For achieving that, we create a config file named .npmrc in the root of our project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e71410b88ed723e8296221fd1545391c/href">https://medium.com/media/e71410b88ed723e8296221fd1545391c/href</a></iframe><p>You notice that :</p><ul><li>Our scope package is : @sb-plugins</li><li>We specified that our package is published in gitlab registry.</li><li>For the project_id you can find it in the setting of the project (look at the picture below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*QacWKuFgOnJK0DsxEJOyfg.png" /></figure><ul><li>Finally, you may be ask about CI_JOB_TOKEN. The answer is :</li></ul><blockquote>when a pipeline job is about to run, GitLab generates a unique token and injects it as the <a href="https://docs.gitlab.com/ee/ci/variables/predefined_variables.html">CI_JOB_TOKEN predefined variable</a>.</blockquote><h4>c. Generate Personal Access Token</h4><p>Too much configurations ? I have a great news : This is the last step 😃</p><blockquote>As part of publishing a package, semantic-release increases the version number in package.json. For semantic-release to commit this change and push it back to GitLab, the pipeline requires a custom CI/CD variable named GITLAB_TOKEN.</blockquote><p>To create this variable check <a href="https://docs.gitlab.com/ee/ci/examples/semantic-release.html#set-up-cicd-variables">this</a>.</p><p>Finally, commit your changes and push it again 🥁🥁🥁.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sg-VqXisg4mbmB7k2ln7rQ.png" /></figure><p>Our pipelines succeeds and if you check your project registry, you will find your package :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADksmF4Vlcv2lC8RuSMwVg.png" /></figure><h3>➕ How to install our package in other projects ?</h3><p>All what we have done have no meaning if we can not use our package in other projects. But, how ?</p><p>If you try directly to install it by using npm, you’ll have this error :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*Jmb5h5dTVOHGodbvVoCK3Q.png" /></figure><p>In fact, npm searches for our package in npm registry that’s why we got Not found error.</p><p>For fixing that, we should tell npm that we want to install this package from gitlab registry. So, let’s create npm config file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1b13e332e7417b13a114ecfc086a857/href">https://medium.com/media/f1b13e332e7417b13a114ecfc086a857/href</a></iframe><p>Now try to install the package again :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*o7DgQ9SSdQBNxMIKtBQ1wg.png" /></figure><h4><strong><em>Bonus </em></strong>🎁</h4><p>If you want to keep your package private :</p><ul><li>Make your project private</li><li>Use your generated personal access token GITLAB_TOKEN to install the package in the desired project (just uncomment line 3 of the .npmrc file)</li></ul><p>Thank you for reading, if you have any questions or remarks please do not hesitate to leave a comment below.</p><ul><li>Link to Gitlab project: <a href="https://gitlab.com/sihemBouh/sb-geometry-plugin">https://gitlab.com/sihemBouh/sb-geometry-plugin</a></li><li>Link to generated documentation in Gitlab pages : <a href="https://sihembouh.gitlab.io/sb-geometry-plugin/">https://sihembouh.gitlab.io/sb-geometry-plugin/</a></li></ul><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><em>. Interested in Growth Hacking? Check out </em><a href="https://circuit.ooo/"><strong><em>Circuit</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94eec41e0770" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/create-your-first-npm-package-and-publish-it-into-gitlab-registry-94eec41e0770">Create Your First NPM Package and Publish It into the Gitlab Registry</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Multilingual Web App Using Vue.js 2 + Vue 18n]]></title>
            <link>https://javascript.plainenglish.io/create-multilingual-web-app-using-vuejs-2-vue-18n-f18eaf47b2a0?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/f18eaf47b2a0</guid>
            <category><![CDATA[composition-api]]></category>
            <category><![CDATA[i18n]]></category>
            <category><![CDATA[multilingual]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuetify]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Fri, 22 Apr 2022 07:25:50 GMT</pubDate>
            <atom:updated>2022-11-16T03:30:20.662Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to create a multilingual web app using Vue.js through a very easy example.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKUuxwY0QVOhPoElnkWe2Q.jpeg" /></figure><p>It’s important to create a multilingual website that supports many languages at the same time in order to increase the popularity of your app and make it more accessible.</p><p>In this tutorial we’ll see how to integrate the vue-i18n plugin in a VueJS app through a simple single page application (personality test result given by 16 personalities) in three different languages: English, Arabic and French.</p><h4>What we will use ?</h4><ul><li><a href="https://vuejs.org/">VueJS :</a> a very popular JavaScript framework for creating web applications.</li><li><a href="https://vuetifyjs.com/en/">Vuetify :</a> a UI Library with beautifully handcrafted Material Components, I’ve used this library to make our example more user friendly.</li><li><a href="https://kazupon.github.io/vue-i18n/">Vue-18n :</a> the official internationalization plugin for VueJS.</li><li><a href="https://yarnpkg.com/package/@vue/composition-api">Composition API plugin for Vue 2 :</a> a new way to write Vue components which allows features to be grouped together logically, rather than having to organize your single-file components by function.</li><li><a href="https://yarnpkg.com/package/vue-demi">Vuedemi:</a> is a developing utility that allows you to write Universal Vue Libraries for Vue 2 &amp; 3</li><li><a href="https://github.com/vueuse/vueuse">Vueuse :</a> is a collection of essential Vue Composition Utilities for Vue 2 &amp; 3.</li></ul><h4>To do list</h4><p>This article is organized as follows :</p><ol><li>Create the project and Install dependencies.</li><li>Set up the vue-i18n plugin.</li><li>Create the logic for translating the app.</li></ol><h3>1. Create the project and Install dependencies</h3><p>The first step is to create a VueJS application and add all plugins and libraries that we need in order to reach our goal.</p><pre># 1 - Create VueJS app using vue-cli<br>$ vue create my-personality<br># 2 - Add Vuetify library<br>$ vue add vuetify<br># 3 - Add plugins<br>$ yarn add @vue/composition-api vue-demi  @vueuse/core</pre><h3>2. Set up the vue-i18n plugin</h3><p>The second step is to install and configure vue-i18n plugin.</p><pre>$ yarn vue-i18n</pre><p>You will be asked to provide some information (look at the picture bellow):</p><ul><li>default language of the project,</li><li>The language of fallback,</li><li>Where is situated /locales directory,</li><li>Either you would like to enable translation in single components or not.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYOYgSTjvZexfrmF8Hrf6g.png" /></figure><p>After that, some files will be added automatically like :</p><ul><li><em>src/i18n.js</em> : in which vue-i18n plugin is configured to be used in src/main.js,</li><li><em>src/locales</em> directory : in which we will add our locales files, every local will be stored in a separate JSON file,</li><li>.env file : which is used for declaring environment variables in our case there is two essential variables:</li></ul><pre>VUE_APP_I18N_LOCALE=en<br>VUE_APP_I18N_FALLBACK_LOCALE=en</pre><h3>3. Create the logic for translating the app</h3><p>Now that our project is well configured, it’s time to talk about how to tell our app which language locale is used and what is the text direction of the app (either from left to right like in Latin languages or from right to left like in Arabic).</p><p>First, we create a new JavaScript file <em>“composables/loacle.js”</em>, that will expose the selected locale language.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/381ee04ffe46152abf56ff7dfaf4fd2c/href">https://medium.com/media/381ee04ffe46152abf56ff7dfaf4fd2c/href</a></iframe><p>In the code above we used :</p><ul><li><strong><em>toRefs :</em></strong> which takes an value of a variable and returns a reactive and mutable ref object, which has a single property .value that points to the variable value.</li><li><strong><em>usePreferredLanguages : </em></strong>it returns reactive <a href="https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages">Navigator Languages</a>, which provides us information about user’s preferred languages.</li><li><strong><em>useStorage :</em></strong> which gives us a nice way to have a reactive entries in local storage of the user browser.</li></ul><p>Now, we can put the text we want to be translated in “<em>locales</em>” directory files. Each file will have the same structure but exposes different values according to the matched language.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cab2c6fcb177d52f5098cabe059d178/href">https://medium.com/media/6cab2c6fcb177d52f5098cabe059d178/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18bd189bccd71df8df236e32f58b4602/href">https://medium.com/media/18bd189bccd71df8df236e32f58b4602/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a6148e493e1de36ed561b7774923253/href">https://medium.com/media/9a6148e493e1de36ed561b7774923253/href</a></iframe><p>After that, the translation will be easy, we just use <strong><em>i18n </em></strong>translation method <strong><em>$t </em></strong>directly in the template of our vue components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b994840edd11c78088c122e8f6009858/href">https://medium.com/media/b994840edd11c78088c122e8f6009858/href</a></iframe><p>And for switching selected language, we just use the value exposed by <strong><em>locale.js </em></strong>file to update the current locale of <strong><em>i18n</em></strong> plugin. For that, we can create a special component responsible for switching language and text direction.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e199e8b5e07e1d2abb330aa7b6320abc/href">https://medium.com/media/e199e8b5e07e1d2abb330aa7b6320abc/href</a></iframe><p>And that&#39;s all, our app is now available in three different languages !!!</p><p>Thanks for reading, and for more details you can check the GitHub repository of the project :</p><p><a href="https://github.com/SihemBouhenniche/i18n-vue-app-example">GitHub - SihemBouhenniche/i18n-vue-app-example: Example of how setting up vue-i18n plugin in vuejs app</a></p><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><em>. Interested in Growth Hacking? Check out </em><a href="https://circuit.ooo/"><strong><em>Circuit</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f18eaf47b2a0" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/create-multilingual-web-app-using-vuejs-2-vue-18n-f18eaf47b2a0">Create a Multilingual Web App Using Vue.js 2 + Vue 18n</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create REST API With Django and Neo4j Database Using Django_nemodel]]></title>
            <link>https://medium.com/swlh/create-rest-api-with-django-and-neo4j-database-using-django-nemodel-1290da717df9?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/1290da717df9</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[graph-database]]></category>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Wed, 29 Jul 2020 17:38:08 GMT</pubDate>
            <atom:updated>2024-03-26T09:46:10.698Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create REST API With Django and Neo4j Database Using Django Neomodel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unpojBSzIGm2HsgOu8hWyg.jpeg" /></figure><p>In this tutorial, I’ll show you how to create a REST API using Django and Neo4j database through a simple example. In order to create this API, we need to use an Object Graph Mapper (OGM) to request the graph database, that’s why we will use django_neomodel which is a Django integration of the awesome OGM neomodel.</p><h4>What will we use ?</h4><ul><li>Django : <strong>Django</strong> is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.</li><li>Neo4j : Neo4j is a NoSQL graph database management system (DBMS).</li><li>Django_neomodel : a module that allows you to use the <a href="https://www.neo4j.org/">n</a>eo4j graph database with Django using <a href="http://neomodel.readthedocs.org/">neomodel</a>.</li></ul><h4>To do list</h4><ol><li>Installing dependencies.</li><li>Create and set up the project.</li><li>Create the graph structure that Django_neomodel ORM will manage.</li><li>Create and manage some objects using Django shell.</li><li>Create views and urls patterns.</li><li>Request our API.</li></ol><h3>1. Installing dependencies</h3><p>Before jumping into the installation, you should have already downloaded python. You can check the actual version for python by this command:</p><pre>$ python --version</pre><p>The first step is to create a virtual environment that will will englobe all the requirements. So let’s start by installing virtualenv and activate the virtual environment:</p><pre>$ pip install virtualenv<br>$ virtualenv env<br>$ env\Scripts\activate</pre><p>Then we install django and django_neomodel:</p><pre>$ pip install Django<br>$ pip install django_neomodel</pre><p>Finally, we install Neo4j. For that i recommend you to use the official documentation of Neo4j. You can find it <a href="https://neo4j.com/docs/operations-manual/current/installation/">here</a>.</p><p>We are ready now to start creating our django API.</p><h3>2. Create and set up the project</h3><p>First of all, we start by creating a neo4j project named “Tutorial”. Then we create a graph database inside it. (look at the figure below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*AbxGzBTfrAAeJB06rBJFlw.png" /><figcaption>Create Neo4j database process</figcaption></figure><p>Now, it’s time to create django project. For that, we use this command:</p><pre>$ django-admin startproject myproject</pre><p>Then, according to the django project structure we must create an application inside this project:</p><pre>$ cd myproject<br>$ python manage.py startapp myapi</pre><p>After that, we need to register our application in myproject/settings.py file so Django can recognize this new application. We must also register django_neomodel and set up the connexion to our neo4j database.</p><pre># Application definition<br><br>INSTALLED_APPS = [<br>    # django.contrib.auth etc  <br>    &#39;myapi.apps.MyapiConfig&#39;,<br>    &#39;django_neomodel&#39;<br>]</pre><pre># Database<br># https://docs.djangoproject.com/en/3.0/ref/settings/#databases<br><br><br>NEOMODEL_NEO4J_BOLT_URL = os.environ.get(&#39;NEO4J_BOLT_URL&#39;,&#39;bolt://username:password@localhost:7687&#39;)</pre><pre># you are free to add this configurations<br>NEOMODEL_SIGNALS = True<br>NEOMODEL_FORCE_TIMEZONE = False<br>NEOMODEL_ENCRYPTED_CONNECTION = True<br>NEOMODEL_MAX_POOL_SIZE = 50</pre><h3>3. Create the graph structure that Django_neomodel ORM will manage</h3><p>Our example is very simple. We will have two entities Person and City and two relationships between them(LivesIn and Friend). see the structure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*4iXc6OtHyrRLhjZ5K4R09Q.png" /><figcaption>Graph structure of our example</figcaption></figure><p>Let’s define our graph structure inside myapi/models.py file like that :</p><pre>from neomodel import StructuredNode, StringProperty, IntegerProperty,UniqueIdProperty, RelationshipTo<br><br># Create your models here.<br><br><br>class City(StructuredNode):<br>    code = StringProperty(unique_index=True, required=True)<br>    name = StringProperty(index=True, default=&quot;city&quot;)<br><br>class Person(StructuredNode):<br>    uid = UniqueIdProperty()<br>    name = StringProperty(unique_index=True)<br>    age = IntegerProperty(index=True, default=0)<br><br>    # Relations :<br>    city = RelationshipTo(City, &#39;LIVES_IN&#39;)<br>    friends = RelationshipTo(&#39;Person&#39;,&#39;FRIEND&#39;)</pre><p>You can find more details about how to define node entities and relationships in <a href="https://neomodel.readthedocs.io/en/latest/">the neomodel official documentation</a>.</p><p>After that, we must create constraints and indexes for our labels to ensure that everything is right by typing this command :</p><pre>$ python manage.py install_labels</pre><p>You can ensure that constraints and were applied in the Neo4j browser like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOzg3B3Lnwkp3ZRwOHnltg.png" /><figcaption>Checking our database schema</figcaption></figure><h3>4. Create and manage some objects using Django shell</h3><p>Now, let’s ensure that everything is all right by populating our database by some persons and cities. For that, we will use simply Django shell:</p><pre>$ python manage.py shell<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>(InteractiveConsole)<br>&gt;&gt; from myapi.models import * <br>&gt;&gt; all_persons = Person.nodes.all()<br>[]<br>&gt;&gt; all_cities = City.nodes.all()<br>[]<br>&gt;&gt; algiers = City(code=&quot;ALG&quot;,name=&quot;Algiers&quot;)<br>&gt;&gt; print(algiers)<br>{code: &quot;ALG&quot;, name: &quot;Algiers&quot;}<br>&gt;&gt; algiers.save()<br>&lt;City: {code: &quot;ALG&quot;, name: &quot;Algiers&quot;, id: 0}&gt;<br>&gt;&gt; sihem = Person(name=&#39;Sihem&#39;, age=24)<br>&gt;&gt; print(sihem)<br>{&#39;uid&#39;: &#39;56329dc&#39;, &#39;name&#39;: &#39;Sihem&#39;, &#39;age&#39;: 24}<br>&gt;&gt; sihem.save()<br>&lt;Person: {&#39;uid&#39;: &#39;56329dc&#39;, &#39;name&#39;: &#39;Sihem&#39;, &#39;age&#39;: 24, &#39;id&#39;: 1}&gt;<br>&gt;&gt; sihem.city.connect(algiers)<br>True<br>&gt;&gt; if sihem.city.is_connected(algiers):<br>...     print(&quot;sihem lives in Algeirs&quot;)<br>...<br>sihem lives in Algeirs<br>&gt;&gt; oussama= Person(name=&#39;Oussama&#39;, age=22)<br>&gt;&gt; oussama.save()<br>&lt;Person: {&#39;uid&#39;: &#39;c139f04&#39;, &#39;name&#39;: &#39;Oussama&#39;, &#39;age&#39;: 22, &#39;id&#39;: 21}&gt;<br>&gt;&gt; oussama.city.connect(algiers)<br>True<br>&gt;&gt; oussama.friends.connect(sihem)<br>True</pre><p>After that, you can check our objects in Neo4j database by using Cypher queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WykvLb6yiS_nyQK0_nuvjg.png" /><figcaption>Showing all created nodes and relationships</figcaption></figure><p>You can create more objects using either Neo4j browser or Django shell.</p><h3>5. Create views and urls patterns</h3><p>Arriving at this stage, it’s time to create our person and city views. So let’s delete myapi/views file and use instead of it a new package named myapi/views. We wil have the following application structure:</p><pre>myapi<br>|_migrations<br>|_models<br>| |_ __init__.py<br>| |_person.py<br>| |_city.py<br>|_views<br>| |_ __init__.py<br>| |_ person.py<br>| |_ city.py<br>| |_ connectors.py<br>|_ ......</pre><p>Now, lets define the content of each file of mayapi/views package :</p><ul><li><strong><em>person.py : </em></strong>this file contains the following methods<strong><em> :</em></strong></li></ul><ol><li>personDetails : in which we will put our CRUD operations (create new person, update, delete and get details of a person).</li><li>getAllPersons : which will render a list of existing Person instances.</li></ol><pre>from django.http import JsonResponse<br>from myapi.models import Person<br>from django.views.decorators.csrf import csrf_exempt<br>import json<br><br><br>def getAllPersons(request):<br>    if request.method == &#39;GET&#39;:<br>        try:<br>            persons = Person.nodes.all()<br>            response = []<br>            for person in persons :<br>                obj = {<br>                    &quot;uid&quot;: person.uid,<br>                    &quot;name&quot;: person.name,<br>                    &quot;age&quot;: person.age,<br>                }<br>                response.append(obj)<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br>@csrf_exempt<br>def personDetails(request):<br>    if request.method == &#39;GET&#39;:<br>        # get one person by name<br>        name = request.GET.get(&#39;name&#39;, &#39; &#39;)<br>        try:<br>            person = Person.nodes.get(name=name)<br>            response = {<br>                &quot;uid&quot;: person.uid,<br>                &quot;name&quot;: person.name,<br>                &quot;age&quot;: person.age,<br>            }<br>            return JsonResponse(response, safe=False)<br>        except :<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>    if request.method == &#39;POST&#39;:<br>        # create one person<br>        json_data = json.loads(request.body)<br>        name = json_data[&#39;name&#39;]<br>        age = int(json_data[&#39;age&#39;])<br>        try:<br>            person = Person(name=name, age=age)<br>            person.save()<br>            response = {<br>                &quot;uid&quot;: person.uid,<br>            }<br>            return JsonResponse(response)<br>        except :<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>    if request.method == &#39;PUT&#39;:<br>        # update one person<br>        json_data = json.loads(request.body)<br>        name = json_data[&#39;name&#39;]<br>        age = int(json_data[&#39;age&#39;])<br>        uid = json_data[&#39;uid&#39;]<br>        try:<br>            person = Person.nodes.get(uid=uid)<br>            person.name = name<br>            person.age = age<br>            person.save()<br>            response = {<br>                &quot;uid&quot;: person.uid,<br>                &quot;name&quot;: person.name,<br>                &quot;age&quot;: person.age,<br>            }<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>    if request.method == &#39;DELETE&#39;:<br>        # delete one person<br>        json_data = json.loads(request.body)<br>        uid = json_data[&#39;uid&#39;]<br>        try:<br>            person = Person.nodes.get(uid=uid)<br>            person.delete()<br>            response = {&quot;success&quot;: &quot;Person deleted&quot;}<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)</pre><ul><li><strong><em>city.py :</em></strong> this file contains the following methods :</li></ul><ol><li>cityDetails : in which we will put our CRUD operations (create new city, update, delete and get details of a city).</li><li>getAllCities : which will render a list of existing City instances.</li></ol><pre>from django.http import JsonResponse<br>from myapi.models import City<br>from django.views.decorators.csrf import csrf_exempt<br>import json<br><br><br>def getAllCities(request):<br>    if request.method == &#39;GET&#39;:<br>        try:<br>            cities = City.nodes.all()<br>            response = []<br>            for city in cities:<br>                obj = {<br>                    &quot;code&quot;: city.code,<br>                    &quot;name&quot;: city.name,<br>                }<br>                response.append(obj)<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br>@csrf_exempt<br>def cityDetails(request):<br>    if request.method == &#39;GET&#39;:<br>        # get one city by name<br>        name = request.GET.get(&#39;name&#39;, &#39; &#39;)<br>        try:<br>            city = City.nodes.get(name=name)<br>            response = {<br>                &quot;code&quot;: city.code,<br>                &quot;name&quot;: city.name,<br>            }<br>            return JsonResponse(response, safe=False)<br>        except :<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>    if request.method == &#39;POST&#39;:<br>        # create one city<br>        json_data = json.loads(request.body)<br>        name = json_data[&#39;name&#39;]<br>        code = json_data[&#39;code&#39;]<br>        try:<br>            city = City(name=name, code=code)<br>            city.save()<br>            response = {<br>                &quot;code&quot;: city.code,<br>            }<br>            return JsonResponse(response)<br>        except :<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>    if request.method == &#39;PUT&#39;:<br>        # update one city<br>        json_data = json.loads(request.body)<br>        name = json_data[&#39;name&#39;]<br>        code = json_data[&#39;code&#39;]<br>        try:<br>            city = City.nodes.get(code=code)<br>            city.name = name<br>            city.save()<br>            response = {<br>                &quot;code&quot;: city.code,<br>                &quot;name&quot;: city.name,<br>            }<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>    if request.method == &#39;DELETE&#39;:<br>        # delete one city<br>        json_data = json.loads(request.body)<br>        code = json_data[&#39;code&#39;]<br>        try:<br>            city = City.nodes.get(code=code)<br>            city.delete()<br>            response = {&quot;success&quot;: &quot;City deleted&quot;}<br>            return JsonResponse(response)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)</pre><ul><li><strong><em>connectors.py :</em></strong> this file contains the following methods :</li></ul><ol><li>connectPaC : which will create a connexion between a person and a city.</li><li>connectPaP: which will create a connexion between two persons.</li></ol><pre>from django.http import JsonResponse<br>from myapi.models import *<br>from django.views.decorators.csrf import csrf_exempt<br>import json<br><br><br>@csrf_exempt<br>def connectPaC(request):<br>    if request.method == &#39;PUT&#39;:<br>        json_data = json.loads(request.body)<br>        uid = json_data[&#39;uid&#39;]<br>        code = json_data[&#39;code&#39;]<br>        try:<br>            person = Person.nodes.get(uid=uid)<br>            city = City.nodes.get(code=code)<br>            res = person.city.connect(city)<br>            response = {&quot;result&quot;: res}<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)<br><br>@csrf_exempt<br>def connectPaP(request):<br>    if request.method == &#39;PUT&#39;:<br>        json_data = json.loads(request.body)<br>        uid1 = json_data[&#39;uid1&#39;]<br>        uid2 = json_data[&#39;uid2&#39;]<br>        try:<br>            person1 = Person.nodes.get(uid=uid1)<br>            person2 = Person.nodes.get(uid=uid2)<br>            res = person1.friends.connect(person2)<br>            response = {&quot;result&quot;: res}<br>            return JsonResponse(response, safe=False)<br>        except:<br>            response = {&quot;error&quot;: &quot;Error occurred&quot;}<br>            return JsonResponse(response, safe=False)</pre><ul><li>__init__.py : this file makes <strong>Python</strong> treat myapi/views directory as one module.</li></ul><pre>from myapi.views.person import *<br>from myapi.views.city import *<br>from myapi.views.connectors import *</pre><p>After that, we create new file inside myapi/ directory called urls in which we will register our list routes URLs to our views.</p><pre>from django.conf.urls import url<br>from myapi.views import *<br>from django.urls import path<br>urlpatterns = [<br>    path(&#39;person&#39;,personDetails),<br>    path(&#39;getAllPersons&#39;,getAllPersons),<br>    path(&#39;city&#39;,cityDetails),<br>    path(&#39;getAllCities&#39;,getAllCities),<br>    path(&#39;connectPaC&#39;,connectPaC),<br>    path(&#39;connectPaP&#39;,connectPaP)<br>]</pre><p>Then, we must register this list routes URLs inside myproject/urls.py file like that :</p><pre>from django.contrib import admin<br>from django.urls import path<br>from django.conf.urls import include<br><br>urlpatterns = [<br>    path(&#39;admin/&#39;, admin.site.urls),<br>    path(&#39;&#39;, include(&#39;myapi.urls&#39;)),<br>]</pre><h3>6. Request our API</h3><p>Finally, we will request our API to ensure that everything works correctly. so let’s start our API by runing this command :</p><pre>$ python manage.py runserver<br>Watching for file changes with StatReloader<br>Performing system checks...</pre><pre>System check identified no issues (0 silenced).<br>July 29, 2020 - 16:48:13<br>Django version 3.0.8, using settings &#39;myproject.settings&#39;<br>Starting development server at <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a></pre><p>To request the API, i used <a href="https://www.postman.com/">Postman</a> which simplify making CRUD requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSh1gNg7qsvvwm4JwqEIPw.png" /><figcaption>List of all persons</figcaption></figure><p>At the end, we can illustrate the architeture of our API like that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*O1dsV-AY5gBdcmNgAMXsHA.jpeg" /><figcaption>Architecture of our API</figcaption></figure><p>Thank you for reading, if you have any questions or remarks please do not hesitate to leave a comment below</p><p>Here is the repository of the whole project in this github link :</p><p><a href="https://github.com/SihemBouhenniche/NeomodelAPI">SihemBouhenniche/NeomodelAPI</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1290da717df9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/create-rest-api-with-django-and-neo4j-database-using-django-nemodel-1290da717df9">Create REST API With Django and Neo4j Database Using Django_nemodel</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behavior driven design (BDD) example on web applications with cucumber and ruby -Part 1-]]></title>
            <link>https://medium.com/@fs_bouhenniche/behavior-driven-design-bdd-example-on-web-applications-with-cucumber-and-ruby-part-1-c89159a43c80?source=rss-a535af0e2f00------2</link>
            <guid isPermaLink="false">https://medium.com/p/c89159a43c80</guid>
            <category><![CDATA[cucumber]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[bdd-testing]]></category>
            <dc:creator><![CDATA[SIHEM BOUHENNICHE]]></dc:creator>
            <pubDate>Tue, 30 Jul 2019 10:47:19 GMT</pubDate>
            <atom:updated>2019-08-06T10:10:43.253Z</atom:updated>
            <content:encoded><![CDATA[<h3>Behavior driven design (BDD) example on web applications with cucumber and ruby</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9FuA_t5JEpMQzyWEIGs_g.png" /></figure><p>In this tutorial we will talk about Behavior driven design (BDD) through a simple example using cucumber and ruby, this concept is very important in every software project, it reduces the communication gaps between team members and make the consumer better understanding.</p><h3>1. what’s BDD ?</h3><p>Behavior-Driven Development (BDD) is a set of practices that aim to reduce some common wasteful activities in software development, such us reworking same work caused by misunderstood or vague requirements, Technical debt, slow feedbacks cycles ….</p><p>BDD can be split into two essential parts : Deliberate Discovery ( The most effective way to do this is through conversation and collaboration between key stakeholders ) and Test-Driven Development ( software development technique where the test is written before the code, it is composed of 3 steps writing failing test, making it pass then refactor it)</p><h3>2. Cucumber :</h3><p>cucumber is a software testing tool supporting Behavior-Driven Development (BDD), cucumber read and execute specifications written in plain text and then validate that the software does what those specifications say.</p><p>specification in cucumber are called scenarios and are written with a specific syntax named Gherkin ( simple set of grammar rules that makes plain text structured enough for Cucumber to understand ), each scenario is composed of sequence of steps, for example :</p><blockquote>Scenario: Signin with email and password</blockquote><blockquote>Given I enter “xxx@yy.zz” in email field</blockquote><blockquote>And I enter “123456” in password field</blockquote><blockquote>Then I should be on my account</blockquote><h3>3. Example :</h3><p>we will take a simple test on google homepage here the scenario that we will test :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c22cc0234acf9bfa0352dcce6b35ac0d/href">https://medium.com/media/c22cc0234acf9bfa0352dcce6b35ac0d/href</a></iframe><p>this scenario validates that google search motor gives us the right results when typing a keyword in the search field.</p><h3>a. installation :</h3><p>first you must :</p><p>* install Ruby</p><p>* install Mozilla navigator ( we will use in this tutorial Mozilla , feel free if</p><p>you want to use another navigator)</p><p>* install Cucumber (on windows use the ruby command prompt and type : gem install cucumber)</p><p>*install bundler with this command : gem install bundler</p><h3>b. creating project structure :</h3><p>now create this structure and we will explain the utility of every file created :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*GFjEIfs60IG6SPxH1PpP5A.png" /><figcaption>project structure</figcaption></figure><p>· <strong>Gemfile</strong> : contains project dependencies, in our context we need : capybara, selenium-webdriver and webdrivers to run your tests in browsers and site-prisme which allows describing your site using the Page Object Model pattern, most of time is used with capybara, the content of this file :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c8ee37d2875cc612200877f3017b7fb/href">https://medium.com/media/0c8ee37d2875cc612200877f3017b7fb/href</a></iframe><p>· <strong>Rakefile </strong>: contains tests tasks to run :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/624c524d077a7e297c34eecc5da99609/href">https://medium.com/media/624c524d077a7e297c34eecc5da99609/href</a></iframe><p>· <strong>dummy.feature</strong> : the feature file, it contains the functionality that we want to validate</p><p>· <strong>dummy_steps.rb</strong> : contains the declaration of each step so that cucumber knows what to do, it looks like that :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83c3c9b3f01887f95feea36a192f733e/href">https://medium.com/media/83c3c9b3f01887f95feea36a192f733e/href</a></iframe><p>· <strong>google_home_helpers.rb </strong>: contains helper methods called in every step definition.</p><p>· <strong>google_home_page</strong>.rb : describe our Modal object page, which is class extended from “SitePrism::Page”, where we declare the URL of the page and its different components by using CSS selectors :</p><blockquote>element :keyword_input, ‘input.gLFyf’)</blockquote><p>This class is used in GoogleHomeHelper to perform action on the webpage components.</p><p>· <strong>host_helpers.rb: </strong>is used to tell capybara the app_host, in our case it’s collected from environments attributes.</p><p><strong>navigation_helpers.rb</strong> : contains “load_google_home”method used for loading the google home page.</p><p>· <strong>env.rb</strong> : without this file our test will not be able to pass, in this file we declare in addition to different dependencies like (cucumber, capybara, site_prism, webdrivers ….), values of some default attributes and some configurations.</p><h3>c. Writing feature test ?</h3><p>The first thing you should create when you want to write a Cucumber test is feature file, in which you include scenario or scenarios you want to execute in the test, this file is written in a specific syntax called Gherkin which is very closed to the human language that’s why it’s very easy to understand by non-developers.</p><p>Every feature file we define a feature, which can be standalone unit or functionality of a project.</p><p>In our case we have a little functionality given by one scenario and four steps, here is a table where we explain the meaning of each line :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*ZtRFF327RrxN2VyyWWNEkg.jpeg" /></figure><p>There is other keywords that we didn’t use in this example for more details check : <a href="https://cucumber.io/docs/gherkin/reference/">https://cucumber.io/docs/gherkin/reference/</a></p><p>After writing feature file, you must explain what every step does, we call that “steps definitions”, in dummy_steps.rb we provide definition for each step, You can find more details about steps definition in : <a href="https://cucumber.io/docs/gherkin/step-organization/">https://cucumber.io/docs/gherkin/step-organization/</a></p><h3>d. Installing dependencies :</h3><p>Now it’s still for you just the installation of requirements, run this command :</p><blockquote>bundle install</blockquote><p>It will generate a Gemfile.lock file</p><p>Finally run the test by this command :</p><blockquote>rake google_search_test</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*McEpQLD3bghwoIBAMS4sjw.jpeg" /><figcaption>Test execution results</figcaption></figure><p>Thank you for reading, if you have any questions or remarks please do not hesitate to leave a comment below</p><p>Here is the repository of the whole project in this github link : <a href="https://github.com/SihemBouhenniche/googleTest">https://github.com/SihemBouhenniche/googleTest</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c89159a43c80" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>