<?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: Siddharth Udeniya</title>
    <description>The latest articles on DEV Community by Siddharth Udeniya (@sid__).</description>
    <link>https://dev.to/sid__</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%2F628336%2F1e56f861-a0f0-4a3f-ba5c-83b57e9d4905.jpeg</url>
      <title>DEV Community: Siddharth Udeniya</title>
      <link>https://dev.to/sid__</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sid__"/>
    <language>en</language>
    <item>
      <title>How to become a Backend Developer in 2021?</title>
      <dc:creator>Siddharth Udeniya</dc:creator>
      <pubDate>Fri, 14 May 2021 08:55:31 +0000</pubDate>
      <link>https://dev.to/sid__/how-to-become-a-backend-developer-in-2021-4652</link>
      <guid>https://dev.to/sid__/how-to-become-a-backend-developer-in-2021-4652</guid>
      <description>&lt;p&gt;Hi Reader! Thanks for the great reaction to &lt;a href="https://dev.to/sid__/why-do-you-need-helmet-in-nodejs-h1b"&gt;my previous post&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I have started publishing my learnings recently and wish to start a personal blog soon but till then you can always follow me here on dev.to and on &lt;a href="https://twitter.com/acerbic_sid"&gt;Twitter&lt;/a&gt; to keep yourself updated with them (my learnings).&lt;/p&gt;

&lt;p&gt;Now coming to the post, I stumbled upon &lt;a href="https://roadmap.sh/backend"&gt;this link&lt;/a&gt; and thought I will share it with you guys. Do check it.&lt;/p&gt;

&lt;p&gt;I plan to cover most of the parts mentioned in that link step by step in different series. Already started with Node and will start databases soon. I have also started a series for folks who know Node.js and want to learn Golang. &lt;/p&gt;

&lt;p&gt;Let me know in the comments what else do you want me to prioritize!! &lt;/p&gt;

&lt;p&gt;Till then, stay safe &amp;amp; take care.&lt;/p&gt;

</description>
      <category>node</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Why do you need Helmet in NodeJs ? </title>
      <dc:creator>Siddharth Udeniya</dc:creator>
      <pubDate>Mon, 10 May 2021 05:27:49 +0000</pubDate>
      <link>https://dev.to/sid__/why-do-you-need-helmet-in-nodejs-h1b</link>
      <guid>https://dev.to/sid__/why-do-you-need-helmet-in-nodejs-h1b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Helmet helps you secure your Express apps by setting various HTTP headers. It's not a silver bullet, but it can help!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are the lines written on top of the npm's helmet page.&lt;/p&gt;

&lt;p&gt;Most of you might have come across this code &lt;code&gt;app.use(helmet())&lt;/code&gt; in your codebase/boilerplates. Let's dive deep into helmet today.&lt;/p&gt;

&lt;p&gt;In simple words, Helmet adds/secures HTTP headers returned by your express app.&lt;/p&gt;

&lt;p&gt;Most of the newbie devs tend to ignore this (secured HTTP headers).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;helmet()&lt;/code&gt; is a wrapper around 15 middlewares, 11 of them are used by default with preset settings.&lt;/p&gt;

&lt;p&gt;Let's see those 11 headers in detail:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;Content-Security-Policy&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Used for mitigating XSS Attacks. Helps control what domain/subdomain, which protocol, what kind of media should talk to the server. &lt;br&gt;
&lt;code&gt;helmet.contentSecurityPolicy();&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-DNS-Prefetch-Control&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;As the name of this header suggests, the browser tries to resolve DNS while (in parallel) loading the page content. DNS resolution for what? - For the links, images, etc referenced on the page which is being loaded. Prefetching occurs in the background. Helps reduce latency. By default, helmet sets this as &lt;code&gt;off&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;helmet.dnsPrefetchControl(options)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;Expect-CT&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;CT in this header stands for &lt;strong&gt;Certificate Transparency&lt;/strong&gt;. Catch that misissued certificate on that site.&lt;br&gt;
&lt;code&gt;helmet.expectCt()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-Frame-Options&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A well-known header to prevent clickjacking up to a certain extent. Gets overridden by &lt;code&gt;frame-ancestors&lt;/code&gt; directive of Content Security Policy header.&lt;br&gt;
&lt;code&gt;helmet.frameguard();&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-Powered-By&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This headers makes very less difference even if turned off. Set to &lt;code&gt;express&lt;/code&gt; by default in Express framework.&lt;br&gt;
&lt;code&gt;helmet.hidePoweredBy()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;Strict-Transport-Security&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;or HSTS in short, tells browsers that the website should only be accessible via HTTP(S) protocol. No HTTP please! Takes one mandatory param &lt;em&gt;max-age&lt;/em&gt; (which is 180 days in helmet) and 2 optional params &lt;em&gt;includeSubDomains&lt;/em&gt; (defaults to true) &amp;amp; &lt;em&gt;preload&lt;/em&gt; (defaults to false) in options. &lt;br&gt;
&lt;code&gt;helmet.hsts(options)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-Download-Options&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Specific to Internet Explorer, this header forces potentially unsafe files and instead downloads them directly, thus preventing script injections since the file is no longer opened in the security context of the site.&lt;br&gt;
&lt;code&gt;helmet.ieNoOpen()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-Content-Type-Options&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;helmet.noSniff sets the X-Content-Type-Options header to nosniff. Browsers in some cases try to guess the MIME types by looking at bytes of resources shared by the server. Hey Browser! Don't do that. That's MIME sniffing. Let me give you a nosniff in the Content Type Options.&lt;br&gt;
&lt;code&gt;helmet.noSniff()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-Permitted-Cross-Domain-Policies&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Ah! That's a little tricky. Check this &lt;a href="https://owasp.org/www-project-secure-headers/#x-permitted-cross-domain-policies" rel="noopener noreferrer"&gt;article&lt;/a&gt; for a detailed description.&lt;br&gt;
&lt;code&gt;helmet.permittedCrossDomainPolicies(options)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;Referrer-Policy&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Server dictates what all referrer information it needs in the &lt;code&gt;Referer&lt;/code&gt; (Oh yeah! That's a misspell) header via &lt;code&gt;Referrer-Policy&lt;/code&gt; header. It defaults to no-referrer in case of using helmet.&lt;br&gt;
helmet.referrerPolicy(options)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;X-XSS-Protection&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Oh, Stop! I detected an xss attack.&lt;br&gt;
If it's 0 - Disables XSS filtering.&lt;br&gt;
If it's 1 - Enables XSS filtering. sanitize and then load if XSS is detected.&lt;br&gt;
If it's 1; mode=block - Enables XSS filtering. Do not sanitize, just stop the rendering altogether.&lt;br&gt;
&lt;code&gt;helmet.xssFilter()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So that was all about the 11 default headers Helmet sets. A snippet from Helmet's &lt;a href="https://www.npmjs.com/package/helmet" rel="noopener noreferrer"&gt;NPM Page&lt;/a&gt;:&lt;/p&gt;

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

</description>
      <category>node</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>javascript</category>
    </item>
    <item>
      <title>From Node to Go | Part 1</title>
      <dc:creator>Siddharth Udeniya</dc:creator>
      <pubDate>Sun, 09 May 2021 14:20:48 +0000</pubDate>
      <link>https://dev.to/sid__/from-node-to-go-part-1-2dib</link>
      <guid>https://dev.to/sid__/from-node-to-go-part-1-2dib</guid>
      <description>&lt;p&gt;Hi Reader! Welcome to the &lt;code&gt;From Node to Go&lt;/code&gt; series. &lt;/p&gt;

&lt;p&gt;This series is basically for all the Node.js developers who want to switch to or learn Golang. But since I am starting this from very very basics of Nodejs as well, this can be used to learn web dev in Node.js as well. &lt;/p&gt;

&lt;p&gt;PRE-REQUISITE for this series: You should know how to run node and go programs and you know the basics of Go. If not, I would recommend doing a quick walk through &lt;a href="https://gobyexample.com/"&gt;here&lt;/a&gt;  (Excellent stuff)&lt;/p&gt;

&lt;p&gt;2 - in - 1 !! Oh Yeah!&lt;/p&gt;

&lt;p&gt;END-GOAL of this series: Writing microservices in Go! with all the jargon like Auth, Async Communication, etc included. &lt;/p&gt;

&lt;p&gt;In this part, we will be focusing on creating a simple HTTP server in Node (NO EXPRESS, just plain simple Node.js) and Golang.&lt;/p&gt;

&lt;p&gt;So let's dive in.&lt;/p&gt;

&lt;p&gt;Creating &lt;code&gt;HTTP server&lt;/code&gt; in Nodejs is simple. You import the HTTP module and call &lt;code&gt;createServer&lt;/code&gt;  function. &lt;code&gt;.listen&lt;/code&gt; tells you on which port you want your HTTP server to listen to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var http = require('http');

http.createServer(function (req, res) {
  res.write('Hello World!'); 
  res.end(); 
}).listen(8080); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go to your browser and open &lt;code&gt;http://localhost:8080/&lt;/code&gt;, you should be able to see the Hello World message there.&lt;/p&gt;

&lt;p&gt;Now let's do the same thing in Golang.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
    "net/http"
)

func main() {
    http.HandleFunc("/", HelloWorld)
    http.ListenAndServe(":8081", nil)
}

//HelloWorld Handler
func HelloWorld(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, World!")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run this go program and now go to your browser and open &lt;code&gt;http://localhost:8081/&lt;/code&gt;, you should be able to see the Hello World message there.&lt;/p&gt;

&lt;p&gt;We imported 2 packages:&lt;br&gt;
&lt;strong&gt;fmt:&lt;/strong&gt; Format I/O  (For further reading: &lt;a href="https://golang.org/pkg/fmt/"&gt;fmt package&lt;/a&gt;)&lt;br&gt;
&lt;strong&gt;net/http:&lt;/strong&gt; Importing HTTP package which is a sub-package inside &lt;code&gt;net&lt;/code&gt; package (does all the networking stuff) (For further reading &lt;a href="https://golang.org/pkg/net/http/"&gt;HTTP package&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Define a handler function for the particular route&lt;/strong&gt; - We defined &lt;code&gt;HelloWorld&lt;/code&gt; handler here. &lt;/p&gt;

&lt;p&gt;In ListenAndServe function we passed the address and &lt;code&gt;nil&lt;/code&gt;, we will discuss this &lt;code&gt;nil&lt;/code&gt; in the next part of this series.&lt;/p&gt;

&lt;p&gt;The HTTP Handler takes 2 arguments here &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An object of type &lt;code&gt;ResponseWriter&lt;/code&gt; which is an &lt;code&gt;interface&lt;/code&gt; in Go (For further reading: &lt;a href="https://golang.org/pkg/net/http/#ResponseWriter"&gt;ResponseWriter&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A pointer to &lt;code&gt;Request&lt;/code&gt; which is a &lt;code&gt;struct&lt;/code&gt; in Golang (For further reading: &lt;a href="https://golang.org/pkg/net/http/#Request"&gt;Request&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should probably be having &lt;a href="https://stackoverflow.com/questions/13255907/in-go-http-handlers-why-is-the-responsewriter-a-value-but-the-request-a-pointer"&gt;this&lt;/a&gt; question in mind right now!&lt;/p&gt;

&lt;p&gt;So that's it. That's how you create a plain simple HTTP server in Node and Golang. Stay tuned for the next parts.&lt;/p&gt;

</description>
      <category>go</category>
      <category>node</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
