<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elson Jose</title>
    <description>The latest articles on DEV Community by Elson Jose (@elsonjose).</description>
    <link>https://dev.to/elsonjose</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F814557%2Ff5068e10-3882-452d-9f76-13d306f3b938.jpeg</url>
      <title>DEV Community: Elson Jose</title>
      <link>https://dev.to/elsonjose</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elsonjose"/>
    <language>en</language>
    <item>
      <title>How to enable Authentication in mongodb ?</title>
      <dc:creator>Elson Jose</dc:creator>
      <pubDate>Tue, 21 Feb 2023 12:42:03 +0000</pubDate>
      <link>https://dev.to/elsonjose/how-to-enable-authentication-in-mongodb--2f61</link>
      <guid>https://dev.to/elsonjose/how-to-enable-authentication-in-mongodb--2f61</guid>
      <description>&lt;p&gt;Lets learn how to enable authentication in a local installation of mongodb. &lt;/p&gt;

&lt;p&gt;Note: &lt;em&gt;These steps are to be done on a linux OS&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Start mongodb deamon&lt;br&gt;
&lt;code&gt;$ sudo systemctl start mongod&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect to mongodb using shell&lt;br&gt;
&lt;code&gt;$ mongosh&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use admin database&lt;br&gt;
&lt;code&gt;$ use admin&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create new user. Replace USER_NAME &amp;amp; USER_PASSWORD with the values that you want.&lt;br&gt;
&lt;code&gt;$ db.createUser(&lt;br&gt;
... {&lt;br&gt;
... user: "USER_NAME",&lt;br&gt;
... pwd: "USER_PASSWORD",&lt;br&gt;
... roles: ["readWriteAnyDatabase"]&lt;br&gt;
... }&lt;br&gt;
... )&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Exit shell&lt;br&gt;
&lt;code&gt;$ exit&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modify the configuration file to enable authentication&lt;br&gt;
&lt;code&gt;$ sudo nano /etc/mongod.conf&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Uncomment security option and add authentication. The previous content will be &lt;br&gt;
&lt;code&gt;#secutiry&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are 2 spaces before the &lt;code&gt;authorization: enabled&lt;/code&gt; line. Save using &lt;code&gt;Ctrl+X&lt;/code&gt;, confirm using &lt;code&gt;Y&lt;/code&gt; and &lt;code&gt;Enter&lt;/code&gt;. After updating configuration it will look like this.&lt;br&gt;
&lt;code&gt;security:&lt;br&gt;
authorization: enabled&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Restart mongod&lt;br&gt;
&lt;code&gt;$ sudo systemctl restart mongod&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the deamon is running and status is active&lt;br&gt;
&lt;code&gt;$ sudo systemctl status mongod&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect to mongoDb using shell.&lt;br&gt;
&lt;code&gt;$ mongosh -u "USER_NAME" -p "USER_PASSWORD" --authenticationDatabase "admin"&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If everything is correct it will connect to the default test database. To verify whether authentication is working use &lt;code&gt;$ exit&lt;/code&gt; command and try to connect to mongoDb using &lt;br&gt;
&lt;code&gt;$ mongosh&lt;/code&gt; and list databases &lt;code&gt;$ show dbs&lt;/code&gt;. It will return an error saying "MongoServerError: command listDatabases requires authentication".&lt;/p&gt;

</description>
      <category>performance</category>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>How to use a different style while reusing a component ?</title>
      <dc:creator>Elson Jose</dc:creator>
      <pubDate>Mon, 20 Feb 2023 05:20:47 +0000</pubDate>
      <link>https://dev.to/elsonjose/how-to-use-a-different-style-while-reusing-a-component--170e</link>
      <guid>https://dev.to/elsonjose/how-to-use-a-different-style-while-reusing-a-component--170e</guid>
      <description>&lt;p&gt;In the CSS of the reusable component, create as many styles you want using '&amp;amp;'. &lt;/p&gt;

&lt;p&gt;Note: Assuming that the &lt;strong&gt;className&lt;/strong&gt; is component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.component{
    // write the common styles here
}

.component {
    &amp;amp;-style1 {
        // write style 1 
    }
    &amp;amp;-style2 {
        // write style 2 
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the &amp;amp;-style1 and &amp;amp;-style2 are the additional styles that has be used while re-using the component. Now when you have to use &amp;amp;-style1, simple add the following CSS classname to the classname attribute of the component. For example&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div classname={"component component-style1"}&amp;gt;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;This may need to passed as a prop to make it dynamic. Passing style={'-style1'} as a prop in the component and inside the component we can use the following.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div classname={"component component"+props.style}&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's it!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>How to simplify importing multiple components in another component ?</title>
      <dc:creator>Elson Jose</dc:creator>
      <pubDate>Sun, 19 Feb 2023 07:30:53 +0000</pubDate>
      <link>https://dev.to/elsonjose/how-to-simplify-importing-multiple-components-in-another-component--17i8</link>
      <guid>https://dev.to/elsonjose/how-to-simplify-importing-multiple-components-in-another-component--17i8</guid>
      <description>&lt;p&gt;Suppose we have multiple components namely Component1, Component2 and Component3. Importing them in the main Component (usually the App Component) will look like this.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import Component1 from './path-to-component1'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;import Component2 from './path-to-component2'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;import Component3 from './path-to-component3'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is repetitive. This can be solved by creating a new js file inside the components directory &amp;amp; exporting the components inside it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export { default as Component1 } from './path-to-component1'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;export { default as Component2 } from './path-to-component2'&lt;/code&gt;&lt;br&gt;
&lt;code&gt;export { default as Component3 } from './path-to-component3'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now inside the main Component (usually the App Component) we can import them using the below one-liner.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { Component1, Component2, Component3 } from './path-of-the-js-file-containing-export-statements'&lt;/code&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to serve angular app to all devices connected to your router ?</title>
      <dc:creator>Elson Jose</dc:creator>
      <pubDate>Sat, 18 Feb 2023 09:44:30 +0000</pubDate>
      <link>https://dev.to/elsonjose/how-to-serve-angular-app-to-all-devices-connected-to-your-router--28ne</link>
      <guid>https://dev.to/elsonjose/how-to-serve-angular-app-to-all-devices-connected-to-your-router--28ne</guid>
      <description>&lt;p&gt;Sometimes you might need to see how your site functions on another actual device. Follow these steps to learn how you can do that on angular.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Find the IP address assigned by your router to the device on which you are planning to serve the angular app. Use the following commands based on you operating systems.&lt;br&gt;
&lt;code&gt;$ ifconfig&lt;/code&gt; // for linux&lt;br&gt;
&lt;code&gt;$ ipconfig&lt;/code&gt; // for windows&lt;br&gt;
In the results you can look for inet followed by the IP address assigned by your router to the device.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then using that IP address use the following command to serve the angular application.&lt;br&gt;
&lt;code&gt;$ ng s --host=&amp;lt;YOUR_IP_ADDRESS_HERE&amp;gt; --port=&amp;lt;PORT_NUMBER&amp;gt;&lt;/code&gt;&lt;br&gt;
You can replace YOUR_IP_ADDRESS_HERE with the result from step 1 and PORT_NUMBER with any available port number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On another device connected to the same router, type the address &lt;code&gt;https://&amp;lt;YOU_IP_ADDRESS_HERE&amp;gt;:&amp;lt;PORT_NUMBER&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Voilà....thats it.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>angular</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
