<?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[Codebase - Medium]]></title>
        <description><![CDATA[Software development obsession. Good practices, tips and interesting stuff about coding - Medium]]></description>
        <link>https://medium.com/codebase?source=rss----91a9ebf7332e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Codebase - Medium</title>
            <link>https://medium.com/codebase?source=rss----91a9ebf7332e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 23:04:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/codebase" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to succeed with Code Reviews]]></title>
            <link>https://medium.com/codebase/how-to-succeed-with-code-reviews-b3b5a99c4187?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/b3b5a99c4187</guid>
            <category><![CDATA[programming-tips]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 17:46:35 GMT</pubDate>
            <atom:updated>2019-01-27T17:46:35.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*cf3ZulQ-5DYJz48VONdpkg.png" /></figure><p>Code Reviews is a super relevant topic in these days, a lot of people think about it just as a bottleneck and other people take it extremely seriously. Let’s talk about how to succeed (for the whole team, not just you) in this super important part in the process of creating software.</p><h3>The problems and how to fix them (or avoid them)</h3><p>Usually, when you finish developing some new feature and you have your Pull Request ready for review, some problems arrive:</p><h4>No one do the review</h4><p>Yes, this is a super common thing. You put all your effort in doing the best that you can and no one review it.</p><p>There is a couple of things that you could improve:</p><ul><li><strong>You notified people in the wrong way</strong>: Maybe just assigning someone on Github PR is not enough? Send the link in a fun way in some Slack channel to grab some attention or just ask some one directly.</li><li><strong>Code Review Buddies</strong>: Yes, just make some code review buddies (one or more) you can always be checking the PR to each other’s and move really fast with your work. It’s kind of a compromise to review to each other.</li><li><strong>Do your part</strong>: Remember that part of this game is that you need to leave some comments, request changes and approve other’s people PR. If you help other people to improve their code, they will help you in the same way. (Or it’s more probable that they will comment something and eventually approve it).</li><li><strong>Too many changes</strong>: One of the most probable causes, is that your PR is tooooo big! So, try to keep your changes short and concise, don’t go crazy refactoring (boy scouting) and try to split your work in more pull requests. Maybe this part of splitting your work can start in your team planning or refinement meetings :).</li></ul><h4>Too many people reviews it</h4><p>And also, we have the opposite problem. You put the code review message in the “General” channel in Slack, and suddenly, lots of guys has time to code review your PR. Now you have too much changes and requests of changes that you have to make sure to solve so you can merge your changes.</p><ul><li>Start asking just one person to review. You can try this with one coworker that you know that will check everything really well and that you trust. Fix his comments first, and then you will have your PR more refined and with one initial approval. Then, communicate in a more broader way to other people to check it out. At this point, people should only leave small comments and approvals.</li><li>Code review buddies (yes, this also works really well to prevent this problem).</li><li><strong>Fix all comments and ask for a second round at the same time</strong>: Don’t just go fixing comments by developer, fix everything first.</li></ul><h4>Technical debates on the comments</h4><p>Typically, Software Developers loves to create some technical debates from time to time. In general, this is a good thing and makes you learn more and to identify some new technologies or technical concepts that you didn’t knew in the past. But, the problem is that some people tend to do this in Code Reviews.</p><p>When having this problem, and the discussion about some change is too heated or too prolonged, you can do the following:</p><ul><li><strong>Stop it right away</strong>: Approach the other developer personally to discuss the comments. Some times, both of you needs a face to face explanation to fully understand the arguments and suggestions.</li><li><strong>Don’t take it personal</strong>: keep it professional.</li><li><strong>Explain yourself using real and consistent arguments:</strong> like design patterns, architecture, style guidelines or even previous experiencies. Try to not only stay with just an opinion.</li><li><strong>Maintain the focus on delivering the feature to the customer:</strong> Some times, someone suggest some different approach for doing the same, compare trade offs of both implementations. Maybe a 0.0001ms improvement in execution time is not necessary, or maybe his suggestion will improve a lot your code maintainability. If the time spent for doing the fix is not that much and this add some real value, improve it!</li><li>When both of you reach an agreement, write the conclusion in the PR.</li></ul><h3>The good things</h3><p>When you have a good rhythm of work, and your coworkers are leaving useful comments, you will see soo many benefits about it:</p><ul><li>It lower the risk of having problems on QA</li><li>Deliver quality features</li><li>You learn a lot from other developers and others learn from you (Knowledge transfer)</li><li>Better teamwork bonding. The feature is not only developed by you, it also include your coworkers skills and the success of the feature is shared between the whole team.</li></ul><h3>Conclusion</h3><p>Remember that team work is essential here. Code Reviews should not block you or your team, it’s a good opportunity to make great things together and to learn from each other.</p><p>If you think that I need to add something, just let me know in the comments, and share your experience as well!</p><p>Hope you guys like this article, have a great day!</p><p>Gonzalo P.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3b5a99c4187" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/how-to-succeed-with-code-reviews-b3b5a99c4187">How to succeed with Code Reviews</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Structure of a NodeJS API Project]]></title>
            <link>https://medium.com/codebase/structure-of-a-nodejs-api-project-cdecb46ef3f8?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/cdecb46ef3f8</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Tue, 27 Mar 2018 03:53:42 GMT</pubDate>
            <atom:updated>2018-03-27T03:52:32.131Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahlqsxuaN5PWdYPjYywN4Q.png" /></figure><p>When starting developing a NodeJS project and learning the all the basic stuff, the first thing that comes to your mind (at least to me) was: “Now, how I structure a real project that solves a real problem?”. At this point, you have only wrote a couple of small projects that make some fun stuff but that don’t look anything like a “production ready” project.</p><p>Obviously, the answer to this require other basics questions that have to be answered before starting to think in how structure your project:</p><ul><li>What is the problem that you want to solve?</li><li>Is NodeJS the right technology to use?</li><li>What role has your NodeJS project?</li><li>With what others components, apps, apis, databases the project will interactuate?</li></ul><p>With this in mind, I will show you a starting point for you to define a structure for a NodeJS project, based in my recent experience of working with NodeJS for a year in a real project for a retail company.</p><h4>The context</h4><p>First thing you need to know is the context of the project. In this case, I will describe you a fictional situation. Let’s assume that you need to develop a solution that has the following responsibilities….</p><ul><li>It should storage basic transactions in a database.</li><li>Has to integrate with some APIs (REST, SOAP) for some third parties logic.</li><li>Other team will develop a web frontend and in the future it could have multiple “frontends”, for example, a mobile application.</li><li>It must be scalable.</li><li>“We need it ASAP” (Let’s say that we negotiate an <a href="https://en.wikipedia.org/wiki/Minimum_viable_product">MVP</a> with the client)</li></ul><p>In summary, you must develop a scalable headless service that must be accesible from multiple applications and it will integrate with some other software components.</p><h4><strong>The architecture</strong></h4><p>Now that we already have a context of what we need to develop, we can define an architecture.</p><p>In this case, for building the described application, the right choice is to use NodeJS, for the following reasons:</p><ul><li>It will not process a lot of data</li><li>It will mostly be a Middleware. Others services will do the heavy lifting.</li><li>Must handle a lot of request from multiple sources. (The async nature is a good thing to have here)</li><li>MVP, you can code it very fast with Javascript :)</li></ul><p>The representation of components of the project would be the following. The blue box is the API REST that we need to develop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*ZPjbp0yungMdrkl0GWQLLg.png" /></figure><h4>The NodeJS Modules</h4><p>For the architecture defined, we will use the following basics NPM modules:</p><p><strong>Express: </strong>This is a web framework for NodeJS that’s perfect for managing http request, creating middlewares, routing endpoints, etc. We will use it to expose the information of the application. <a href="http://expressjs.com/">http://expressjs.com/</a></p><p><strong>Axios: </strong>A veeeery nice module that I love to use to communicate to other APIs is a very simple, promise based HTTP client called Axios. You can use it to make very simple requests (like, just GET or POST requests), and also, make more complex implementations that send specific custom headers, configure timeouts, authentication, proxys, etc. <a href="https://www.npmjs.com/package/axios">https://www.npmjs.com/package/axios</a></p><p><strong>Sequalize</strong>: This is a promise based ORM for NodeJS that you can use to model and access data from different databases (MySQL, MSSQL, PostgreSQL, SQLite). So here you can manage migrations, queries, transactions, seeds and a lot more. <a href="http://docs.sequelizejs.com/">http://docs.sequelizejs.com/</a></p><p><strong>PM2</strong>: This tool helps you to manage Node apps processes in production environment. <a href="https://www.npmjs.com/package/pm2">https://www.npmjs.com/package/pm2</a></p><p><strong>ShipitJS</strong>: Deployment automation tool (a Capistrano alternative for NodeJS developers). <a href="https://github.com/shipitjs/shipit">https://github.com/shipitjs/shipit</a></p><p>Obviously, you can use more NPM modules, but for this example, I’m presenting you just a couple of modules that I think are very useful and that you can use from a very basic to an advanced project.</p><h4>The Structure</h4><p>NodeJS/Javascript have a characteristic that some people find usefull, but it can make you go deep in the wrong way, and this is the freedom of choose how you want to structure your project (Remember that NodeJS is not a framework like Rails or .Net). Only the experience working in different projects will let you define the best structure for every situation.</p><p>I suggest the following structure:</p><pre>.<br>├── config                  # App configuration files<br>│   ├── sequalize.json        # Sequalize config<br>│   ├── serviceOne.json       # ServiceOne config<br>│   └── ...                 # Other configurations<br>├── routes                  <br>│   ├── controllers         # Request managers<br>│   ├── middlewares         # Request middlewares<br>│   └── routes.js           # Define routes and middlewares here<br>├── services                # External services implementation   <br>│   ├── serviceOne<br>│   └── serviceTwo<br>│   └── ...                 # Other services<br>├── db                      # Data access stuff  (Sequalize mostly)<br>│   ├── models              # Models<br>│   ├── migrations          # Migrations<br>│   ├── seeds               # Seeds<br>│   └── index.js            # Sequalize instantiation<br>├── core                    # Business logic implementation<br>│   ├── accounts.js         <br>│   ├── sales.js            <br>│   ├── comments.js              <br>│   └── ...                 # Other business logic implementations<br>├── utils                   # Util libs (formats, validation, etc)<br>├── tests                   # Testing<br>├── scripts                 # Standalone scripts for dev uses<br>├── pm2.js                  # pm2 init<br>├── shipitfile.js           # deployment automation file<br>├── package.json           <br>├── README.md         <br>└── app.js                  # App starting point</pre><h4>The conclusion</h4><p>This folder structure follows the idea of making things simple. Don’t over engineer things, keep it simple! Maybe your project is simpler than what we are using as an example here, so go on and make it lighter :)</p><p>But what if the project gets bigger? You can modularize the structure grouping your core files into subfolders that represent different components of your application (like Users, Administration, Statistics, etc). Other way to modularize it is to create different projects and deploy each one as a different process or service, so you can have multiple independent projects (this is called Microservices).</p><p>And remember, when creating project structures, just pick the easiest thing that you could make and do it! don’t over engineer it and just do it!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FiXDe1s3spQUZG%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FiXDe1s3spQUZG%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FiXDe1s3spQUZG%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1130077ca3c7bc0a6092a086c03264d/href">https://medium.com/media/b1130077ca3c7bc0a6092a086c03264d/href</a></iframe><p>Thank you for reading!, I hope to create a small project soon with this structure, so you can use it as a boilerplate or as an example that you can follow.</p><p>Regards!</p><p>Gonzalo.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdecb46ef3f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/structure-of-a-nodejs-api-project-cdecb46ef3f8">Structure of a NodeJS API Project</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using AWS S3 Buckets in a NodeJS App]]></title>
            <link>https://medium.com/codebase/using-aws-s3-buckets-in-a-nodejs-app-74da2fc547a6?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/74da2fc547a6</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Tue, 16 Jan 2018 22:41:23 GMT</pubDate>
            <atom:updated>2018-01-16T22:41:22.752Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*RjFjQ29bqVKlBsrzEwIO6A.jpeg" /></figure><p>AWS S3 is a simple storage service offered by Amazon AWS that give you the ability to use it as a webservice. Imagine a Dropbox or Google Drive that allows you to upload or download files programmatically with an API.</p><p>We will go through all the process of using a S3 with NodeJS, from creating the S3 Bucket and access credentials to actually use the bucket.</p><p>First, you need to know how a few concepts:</p><ul><li>S3 Bucket: is a storage unit from the S3 service from Amazon. You can store different type of files (data) and have metadata that describes the actual data or file.</li><li>Access Key ID: Is the identification for a certain access key that allows an application or user to access a set of preconfigured AWS Resource (like a S3 Bucket for example).</li><li>Secret Access key: Is the secret part of the Access Key ID. Think of it as a password for a specific Access Key ID (they must be used always in pairs)</li></ul><p>Now that we understand all of this concepts, we must configure the Amazon Console before start coding.</p><h4>Step 1: Get your key pairs</h4><p>The easy way to obtain a key pair is to create them for your default account for AWS Console.</p><p>Go to the top bar and click your user account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVHPA5HjAaVPx-g_L-673w.png" /></figure><p>Then, click in “My security credentials” and “Access keys”, finally, click “Create New Access Key”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKRMQUWbhei68kqI3y8DNA.png" /></figure><p>A modal window should pop and it will tell you that your access key pairs have been created. Click in “Show access key” to see both of the keys</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*AVDbXBDpBbEtFUqzPOVz3A.png" /></figure><p>Copy and store them in a secure place. We will use them later.</p><h4>Step 2: Create a Bucket</h4><p>Go to “Services/Storage/S3” and then click in “Create Bucket”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*sl55B-gVM9qEqPm5EwtLSg.png" /></figure><p>Then, fill the information required in the form. The bucket name must be unique, so be creative :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*5KXVm5Zwy17NBIyl32RDVw.png" /></figure><p>For this example we are leaving the properties and permissions with the default values</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*pphb1nTGH-Ppp86tnrl86Q.png" /></figure><p>Click next, next, next and you will have the bucket created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mc6WNcDXImy_wXyM1VF8hA.png" /></figure><p>The way that we will need to identificate the bucket is with the “Bucket name” (in this case is “creative-bucket-name-6355123”). So keep it in mind for later use.</p><h4>Step 3: Creating a Node JS project an example file for upload</h4><p>Before you start coding, let’s create the basic project.</p><p>Create a blank project using the command and typing the information required (project name, repo, licence, etc).</p><pre>npm init</pre><p>Then, create a folder in the root directory with the name “data” and create a text file called “file.txt” with the following content:</p><pre>Hi, I am a file uploaded to S3 resource using NodeJS :)</pre><p>Now, go to the root folder and write the following command to install the AWS Package of NPM inside the project.</p><pre>npm install aws-sdk --save</pre><p>Now, create a “index.js” file in the root folder and put the following content</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0139f1e44702618356ed60d5caba5dd6/href">https://medium.com/media/0139f1e44702618356ed60d5caba5dd6/href</a></iframe><p>Now, replace the following text:</p><ul><li>Replace in Line 7, “&lt;Access Key Here&gt;” with the Access Key ID from the step 1.</li><li>Replace in Line 8, “&lt;Secret Access Key Here&gt;” with the Secret Access Keyfrom the step 1.</li><li>Replace in Line 16, “&lt;Bucket Name here&gt;” with your Bucket name created in the step 2.</li></ul><p>All set, if you run “npm start” you should see a console message indicating the URL of the file uploaded. Go to your AWS console and check if your file is up.</p><p>The key parts of this code are:</p><ul><li>Line 6: Access configuration</li><li>Line 12: File to upload</li><li>Line 15: Upload parameters</li><li>Line 21: Uploading file and response callback (second parameter with the function).</li><li>Line 23: Handling error</li></ul><p>That’s it! you can leave questions or doubts that you could have in the comments area bellow and I will complement the post.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74da2fc547a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/using-aws-s3-buckets-in-a-nodejs-app-74da2fc547a6">Using AWS S3 Buckets in a NodeJS App</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unable to obtain lock file access (Dotnet CLI)]]></title>
            <link>https://medium.com/codebase/unable-to-obtain-lock-file-access-dotnet-cli-3bd313a5009c?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/3bd313a5009c</guid>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Tue, 16 Jan 2018 21:45:15 GMT</pubDate>
            <atom:updated>2018-01-16T21:45:14.698Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CQ0rrFrTp6hcUkWuMrD3QQ.png" /></figure><p>If you are having the following error on the “dotnet cli” on linux, I will show you what is the problem and how I fixed it.</p><p>I was using the dotnet cli on linux, creating a couple of projects and suddenly this error appears:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*3_s1ewV_QJxlthyOWsPGSQ.png" /></figure><blockquote>Unable to obtain lock file access on /tmp/NuGetScratch/…..</blockquote><p>What that means? you are executing the “dotnet run” command as a user (my case is “gonzalo”) and the project was created using “sudo”. The owner of the temp folder of nuget is the root user and not “gonzalo”.</p><p>You can check it with the simple and useful “ls -l” on the tmp folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*Tpwv-BOgxxNLt41cINpn4Q.png" /></figure><p>So, to fix it, write the following command on the terminal:</p><pre>sudo chown -R &lt;user&gt;:&lt;user&gt; /tmp/NuGetScratch/</pre><p>(Please replace &lt;user&gt; with your actual username). This will change the owner of the folder and all subfolders to your user, so it will not be exclusive for the root account.</p><p>The result with the “ls -l” again:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*1N7BqZFU87iaPg0sIugogw.png" /></figure><p>And now try to run the app with “dotnet run” (remember, don’t use sudo when working with the project):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*ZXZ6IHxo0WrXqTblvakFDA.png" /></figure><p>Make sure that this configuration is made only in your development environment. And please be careful to not apply chown -R in the root foler “/”!.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*7Pfgey4xXMIYzmvMNa3PtQ.jpeg" /></figure><p>Now, keep coding and learning!</p><p>Gonzalo.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bd313a5009c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/unable-to-obtain-lock-file-access-dotnet-cli-3bd313a5009c">Unable to obtain lock file access (Dotnet CLI)</a> was originally published in <a href="https://medium.com/codebase">Codebase</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 keep multiple linux terminals running in background (Screen)]]></title>
            <link>https://medium.com/codebase/how-to-keep-multiple-linux-terminals-running-in-background-screen-ccf2e53b0d22?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/ccf2e53b0d22</guid>
            <category><![CDATA[linux-console]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[screen-command]]></category>
            <category><![CDATA[linux-terminal]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Wed, 20 Dec 2017 00:57:34 GMT</pubDate>
            <atom:updated>2017-12-20T00:57:33.792Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*Bd4_360JT4WKc3oY.jpg" /></figure><p>Screen is a command that let you have multiple terminals with diferent sessions running at the same time. Usually, the perfect moment to use this is when you need to keep running some process and also execute other commands at the same time using SSH.</p><p>Here I will list some basic commands to start using screen.</p><p><strong>Install screen </strong>(Depends on the Linux Distribution if it came pre installed or not)</p><pre>yum install screen</pre><p><strong>Initiate a Screen</strong></p><pre>screen -S &lt;screen name&gt; &lt;command to execute&gt;</pre><p><strong>Detach from the screen</strong></p><pre>CTRL + A, D</pre><p><strong>List all the screen currently working</strong></p><pre>screen -ls</pre><p><strong>Reattach to a screen</strong></p><pre>screen -r &lt;screen name&gt;</pre><p><strong>Kill specific screen</strong></p><pre>screen -X -S &lt;screen name&gt; quit</pre><p>Also, you can write just a part of the screen name and it will work too (obviously if there is no other process with that name or part of the name).</p><p><strong>Kill all screens</strong></p><pre>pkill screen</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccf2e53b0d22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/how-to-keep-multiple-linux-terminals-running-in-background-screen-ccf2e53b0d22">How to keep multiple linux terminals running in background (Screen)</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MERN EP03: Developing the Front-End with NodeJS, ReactJS and Bootstrap 3]]></title>
            <link>https://medium.com/codebase/mern-ep03-developing-the-front-end-with-nodejs-reactjs-and-bootstrap-3-eda5aba8f8d6?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/eda5aba8f8d6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Fri, 28 Jul 2017 04:02:28 GMT</pubDate>
            <atom:updated>2017-07-28T04:10:11.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxEVnCXTdEWR1HzD0_QBQQ.png" /></figure><p>First, we need to go to our solution folder. remember about our folder structure created in the last post? let’s refresh that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cacfa660151c5a082765f96b43e5ae7/href">https://medium.com/media/9cacfa660151c5a082765f96b43e5ae7/href</a></iframe><p>So, let’s hop in!</p><h3>Create the react app</h3><p>Go to the root folder of the project</p><pre>cd todolist-reactjs-example</pre><p>Now, we are going to use a boilerplate to create the base project for our reactjs app. The boilerplate is “create-react-app”, but you need to install it with NPM first:</p><pre>sudo npm install -g create-react-app</pre><p>So, following the solution architecture explained a little back, we are going to create the front-end project:</p><pre>create-react-app react-frontend</pre><p>When finished, you should be seeing something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*H8iylMN9dInKBZBwbP5Xug.png" /></figure><p>Now, let’s start the app and test if it works! type:</p><pre>cd react-frontend<br>npm start</pre><p>This will start the development server, and when it’s ready, it will open your explorer with the app url:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*V2JuHmc_m6QOoXK2yYzO9Q.png" /></figure><p>But remember that we are going to work with Docker, so let’s shutdown the service (CTRL+C) and start the containers with docker-compose:</p><pre>cd ..<br>sudo docker-compose up</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*HoejnQFZaH67AqG83aybDQ.png" /></figure><p>Open in the explorer: <a href="http://localhost:3000/">http://localhost:3000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*LlqPdz_dIiqvHYGYPAv-yg.png" /></figure><h3>Building the Application</h3><p>The next step after creating the base of the project, is to start building the application.</p><p>First, create the <strong>component</strong> folder inside the <strong>src</strong> directory and create all the files that we are going to use in this project:</p><pre>mkdir src/components/<br>touch src/components/AddTodo.js<br>touch src/components/Header.js<br>touch src/components/ListTodo.js<br>touch src/components/ListTodoRow.js<br>touch src/components/TodoService.js<br>touch src/components/UpdateTodo.js<br>touch src/index.js</pre><p>Now, you need to install the <a href="https://www.npmjs.com/package/react-router">react router</a> and <a href="https://www.npmjs.com/package/axios">axios</a> package:</p><pre>sudo npm install react-router-dom --save<br>sudo npm install axios --save</pre><p>React Router will help you with routing the different components (you can see it working in the index.js file later). On the other hand, Axios will make the connections to the backend, in a very similar way than the classic “jQuery Ajax” do it.</p><h4>Service Class</h4><p>Let’s create the service that is going to connect to the back-end (Simple CRUD):</p><p>File: TodoService.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f655d6c1f3cbd04159e242ab9635286c/href">https://medium.com/media/f655d6c1f3cbd04159e242ab9635286c/href</a></iframe><h4>Index Page (List the Tasks)</h4><p>In this component we are going to list all our tasks and we will set all the buttons for the actions (Add, Delete, Update).</p><p>In the body part of the table, we are going to render the component “ListTodoRow” (The next component after this one).</p><p>File: ListTodo.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/996fcdddfe4c1378ab187be001bdd4c6/href">https://medium.com/media/996fcdddfe4c1378ab187be001bdd4c6/href</a></iframe><h4>Rows of the list</h4><p>This component it’s going to be rendered for every task inside the table.</p><p>File: ListTodoRow.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fea79dc145d1c2a8cd3067f8eb83de1/href">https://medium.com/media/7fea79dc145d1c2a8cd3067f8eb83de1/href</a></iframe><h4>Add Tasks</h4><p>This is a simple form with just one input for adding a new task. The state is just the value of the input that represents the description of the task.</p><p>The handler of the form submit (handleSubmit) will call the todoService (declared in the constructor) and will send all the data to the backend.</p><p>File: AddTodo.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fec95dcfb618a265772f06b859261873/href">https://medium.com/media/fec95dcfb618a265772f06b859261873/href</a></iframe><h4>Update a Task</h4><p>Simple form for updating a task. In this case, we are storing in the state the ID and the Description of the current task, that we send later to the backend in the handleSubmit handler.</p><p>File: UpdateTodo.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7305f8eee2b7f6abd6ab3eb1b2a3c2c1/href">https://medium.com/media/7305f8eee2b7f6abd6ab3eb1b2a3c2c1/href</a></iframe><h4>Header of the app</h4><p>Just the app header.</p><p>File: Header.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b9f6f45c293a8dce200094dae1ccf6e/href">https://medium.com/media/5b9f6f45c293a8dce200094dae1ccf6e/href</a></iframe><h4>Index of the App</h4><p>This is the starting point of the app, that renders the different components depending on the route (Using React Route). The path attribute says with what route the component is going to be rendered in that location in the HTML.</p><p>Also, you can reference a full component as a tag, like “&lt;Header/&gt;”.</p><p>File: index.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54f7d8e655098e0ca75d1fbf9211e047/href">https://medium.com/media/54f7d8e655098e0ca75d1fbf9211e047/href</a></iframe><h4>Style CSS file</h4><p>Just the CSS file that will make things prettier :)</p><p>File: index.css</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6efbdead4b8e5eb7e25bd13d8e9eab95/href">https://medium.com/media/6efbdead4b8e5eb7e25bd13d8e9eab95/href</a></iframe><h4>Index Html (HTML App container)</h4><p>Now we are going to add the reference of the Bootstrap 3 CSS file (From a CDN).</p><p>Add the following line in the header:</p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&quot; integrity=&quot;sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u&quot; crossorigin=&quot;anonymous&quot;&gt;</pre><p>The full file should look like this:</p><p>File: /public/index.html</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d53a25e95df8f725a5cfda5dd5539e1/href">https://medium.com/media/9d53a25e95df8f725a5cfda5dd5539e1/href</a></iframe><h3>Testing the App</h3><p>Now the app it’s ready, let’s see how it look:</p><p>(Remember that you need to start the service with Docker Compose)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*55KLxYqTzb5bU_ftB3ccTw.png" /></figure><p>Play a little with this mini app and add some new tasks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*h9XcSuyK0B0377sJ9VAUjw.png" /></figure><p>And we are done! it’s all working (hope is the same for you, let me know if you have some problem!).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o7qE32pRVNYJYKGBO%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7qE32pRVNYJYKGBO%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7qE32pRVNYJYKGBO%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/b33d7c9a86120f57517574b19105daa4/href">https://medium.com/media/b33d7c9a86120f57517574b19105daa4/href</a></iframe><p>If you want to download the full project, go to the repository in GitHub:</p><p><a href="https://github.com/gonzalompp/todolist-reactjs-example">https://github.com/gonzalompp/todolist-reactjs-example</a></p><p>Also, I will be putting here the link for the following chapter of our series. Leave some comments below!</p><p>Happy Coding!</p><p>Gonzalo</p><h3>PREVIOUS</h3><h4><a href="https://medium.com/codebase/mern-ep02-developing-the-back-end-with-mongodb-nodejs-and-express-556a6748b550">MERN EP02: Developing the Back-End with MongoDB, NodeJS and Express</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eda5aba8f8d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/mern-ep03-developing-the-front-end-with-nodejs-reactjs-and-bootstrap-3-eda5aba8f8d6">MERN EP03: Developing the Front-End with NodeJS, ReactJS and Bootstrap 3</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MERN EP02: Developing the Back-End with MongoDB, NodeJS and Express]]></title>
            <link>https://medium.com/codebase/mern-ep02-developing-the-back-end-with-mongodb-nodejs-and-express-556a6748b550?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/556a6748b550</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Sun, 23 Jul 2017 18:31:37 GMT</pubDate>
            <atom:updated>2017-07-28T04:03:56.136Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v44xXgAw96Ub5VJVqu2kvA.png" /></figure><p>Now that we got our Docker Environment set, we are going to create our backend application that will work as a Middleware between the React JS app and the MongoDB database.</p><p>First, let’s see the folder tree of the project:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cacfa660151c5a082765f96b43e5ae7/href">https://medium.com/media/9cacfa660151c5a082765f96b43e5ae7/href</a></iframe><h3>Installing NodeJS &amp; NPM</h3><p>In this post we are going to start using NodeJS and NPM. So, please read the following post for installing it (it’s very simple):</p><p><a href="https://medium.com/codebase/installing-nodejs-and-npm-44f2c8e8de8e"><strong>Installing NodeJS and NPM</strong></a></p><p>Now we can continue :)</p><h3>Initializing the project</h3><p>We are currently working with the <strong>backend</strong>, so let’s go to the “node-backend” folder and initialize a Node JS project in there:</p><pre>cd node-backend<br>npm init</pre><p>Write all the information requested or just press enter until the confirmation. You should be seeing something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*TmoiauSijzgi9wmeQ80tGw.png" /></figure><p>Now, let’s install <a href="http://expressjs.com/">Express</a> (Web server package for NodeJS), Mongoose (MongoDB plugin for NodeJS) and body-parser (body parsing) and cors (Cross origin requests):</p><pre>sudo npm install express --save<br>sudo npm install mongoose --save<br>sudo npm install body-parser --save<br>sudo npm install cors --save</pre><p>Next, we are going to create the folders of the app:</p><pre>mkdir src<br>mkdir src/models<br>mkdir src/routes</pre><p>Then, let’s create the files that we are going to use:</p><pre>touch app.js<br>touch src/models/TodoList.js<br>touch src/routes/todoListRoutes.js</pre><h3>Building the service</h3><p>Let’s build the service! fill the files created before with the following content:</p><h4>The Model</h4><p>Here we are using Mongoose (MongoDB plugin) to define the model of the item with we will work in the Backend. Just a single valued item (desc) of type string.</p><pre>src/models/TodoList.js</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07975cb7660d7ccccc9079b1c47bd2e3/href">https://medium.com/media/07975cb7660d7ccccc9079b1c47bd2e3/href</a></iframe><h4>The Routes</h4><p>Now we are defining the routes that the Express server will be attending. a basic CRUD.</p><pre>src/routes/todoListRoutes.js</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed36d3b4e6b51462912c9cb7b4fa05ab/href">https://medium.com/media/ed36d3b4e6b51462912c9cb7b4fa05ab/href</a></iframe><h4>The App</h4><p>Finally, we define the application and set up all the configuration:</p><ul><li>Will launch with the base path “/Todo”</li><li>Using port 6200</li><li>Connection string to Mongodb (The service name of the Docker Container works as a domain in the containers network, so the path to the container with MongoDB running is <strong>“mongodb”</strong>. This was configured in the last post, on the <strong>“docker-compose.yml”</strong> file)</li><li>Using url encoding and json as response</li></ul><pre>app.js</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e466f04a3b089c982a64542e634f7c79/href">https://medium.com/media/e466f04a3b089c982a64542e634f7c79/href</a></iframe><h4>Starting the service</h4><p>The last part to making the service work, is to configure the command that will launch the server. In the <strong>package.json</strong> file, add the following configuration:</p><pre>&quot;start&quot;: &quot;nodemon app.js&quot;</pre><p>The file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ff5accf87a1fa61de8b20c27f6ddfe7/href">https://medium.com/media/2ff5accf87a1fa61de8b20c27f6ddfe7/href</a></iframe><p>Now, you can start the server and check the endpoints. Execute the following command in the terminal (remember that we were in the <strong>“node-backend”</strong> folder, so move back to the previous directory first):</p><pre>cd ../<br>sudo docker-compose up</pre><p>You should be seeing something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*cTUTxI974PtylCsRHEDC1g.png" /></figure><p>The container “backend_1” will send the message “Backend Started”, this is the signal that all is working. Now enter to this URL:</p><pre><a href="http://localhost:6200/todo">http://localhost:6200/todo</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*9qwEna82lrhhuESZYoFF2w.png" /></figure><p>This is the endpoint that lists all the task items in the database. Currently is empty, so it’s showing an empty array. It works!</p><p>A little test</p><p>You can install Postman to test the backend (<a href="https://blog.bluematador.com/posts/postman-how-to-install-on-ubuntu-1604/?utm_source=hootsuite&amp;utm_medium=twitter&amp;utm_campaign=">Link here</a>). Let’s insert a new task:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*DmoT8RL0Wxi7W4t76X_GuA.png" /></figure><p>And now, let’s check again the list of task (but now with postman).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*4UXRl7wWI0wA6baIUrl_Sg.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F13lcRkh1KhUGoU%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F13lcRkh1KhUGoU%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F13lcRkh1KhUGoU%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ea191f0aa0ad265e9c5ba11a1df517b/href">https://medium.com/media/6ea191f0aa0ad265e9c5ba11a1df517b/href</a></iframe><p>Congrats! it’s working now!</p><p>Check the full code of this app on the following GitHub repository:</p><p><a href="https://github.com/gonzalompp/todolist-reactjs-example">https://github.com/gonzalompp/todolist-reactjs-example</a></p><p>Now let’s wait for the front-end part :)</p><p>Happy Coding!</p><p>Gonzalo.</p><h3>NEXT</h3><h4><a href="https://medium.com/codebase/mern-ep03-developing-the-front-end-with-nodejs-reactjs-and-bootstrap-3-eda5aba8f8d6">MERN EP03: Developing the Front-End with NodeJS, ReactJS and Bootstrap 3</a></h4><h3>PREVIOUS</h3><h4><a href="https://medium.com/codebase/mern-ep01-setting-up-a-development-environment-with-docker-1bb0b6e4d464">MERN EP01: Setting up a development environment with Docker</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=556a6748b550" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/mern-ep02-developing-the-back-end-with-mongodb-nodejs-and-express-556a6748b550">MERN EP02: Developing the Back-End with MongoDB, NodeJS and Express</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MERN EP01: Setting up a development environment with Docker]]></title>
            <link>https://medium.com/codebase/mern-ep01-setting-up-a-development-environment-with-docker-1bb0b6e4d464?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/1bb0b6e4d464</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[mern]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Fri, 21 Jul 2017 05:10:06 GMT</pubDate>
            <atom:updated>2017-07-23T18:36:49.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2MyGs5ia2kLc0-_jM5RXg.png" /></figure><p>First, we are going to setup a Docker environment following the architecture of our project, but first, let me introduce a few things about Docker!</p><h3>What is Docker?</h3><p>Docker is a software container platform that allows you to create isolated environments (containers) in a very similar way how the virtual machines works, but simpler. Each container is a very small virtual machine that not contains a full OS, but just what it need to make your project work. For example, you can run in your machine (the host) two containers, one for the apache server and another one for the database, one working with linux and the other one with windows.</p><p>(Read more on <a href="https://www.docker.com/what-docker">https://www.docker.com/what-docker</a>)</p><p>So, you can have one Docker Container for each “piece” of your architecture. The good thing is that Docker has a “Docker Compose”, wich is a Tool that orchestrate the containers. Think about a food recipe that list all that you need to make the food you want to cook. Simple as that!</p><h3>Solution Architecture</h3><p>The architecture for the solution is very simple:</p><h4>Database</h4><p>We are going to use <a href="https://www.mongodb.com/">MongoDB</a> as the Database. This is a NoSQL database that store JSON-like documents that don’t have a fixed structure and is Schema-Less. Flexibility is the key benefit.</p><h4>Back-End</h4><p>For the Backend we are going to use NodeJS and Express as the server. We will be running a Javascript server side application (REST API) that will be the middleware between the client and the database.</p><h4>Front-End</h4><p>For the client side, we are going to use:</p><ul><li>NodeJS: Javascript Runtime</li><li>ReactJS: Facebook’s Javascript Library for user interface</li><li>Bootstrap 3: HTML, CSS and JS Framework for web development</li></ul><h3>Installing Docker</h3><p>We are assuming that you are working in Linux (Ubuntu or some Debian distribution). So, please proceed to install Docker Community Edition on your machine.</p><p><a href="https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/">Get Docker CE for Ubuntu</a></p><p>Then, install Docker Composer:</p><pre>sudo apt install docker-compose</pre><h3>Creating the folder Structure</h3><p>Having Docker installed, we need to create the folder structure of the solution:</p><ul><li>We will create the solution root folder “todolist-reactjs-example”. Then, inside create an empty text file named “docker-compose.yml”.</li><li>Create the folders “node-backend” and “react-frontend”, each one with an empty file named Dockerfile.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cacfa660151c5a082765f96b43e5ae7/href">https://medium.com/media/9cacfa660151c5a082765f96b43e5ae7/href</a></iframe><p>That’s the basic folder structure for our project.</p><ul><li>docker-compose.yml: This file defines the multiple containers that the solution will need. (<a href="https://docs.docker.com/compose/overview/">Read more</a>)</li><li>Dockerfile: This file have the instructions to build the image for each container. (<a href="https://docs.docker.com/engine/reference/builder/">Read more</a>)</li></ul><h3>Setting up the Docker Environment</h3><p>Now, let’s make the Docker magic happen:</p><h4>File “todolist-reactjs-example/node-backend/Dockerfile”</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5adb4d39df53ab14a13d63770743d10/href">https://medium.com/media/d5adb4d39df53ab14a13d63770743d10/href</a></iframe><p>Here, we are telling to Docker to build a container with the image “node” in the version 6.11.1. Then, Create and set the working directory to “/user/src/app” (here our backend app will live). Finally, it will have to RUN the command “npm install -g nodemon” (a Node JS Module that restart the server automatically and compiles the app every time you modify some file) and exposes the 3000 port.</p><h4>File “todolist-reactjs-example/react-frontend/Dockerfile”</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0706d367a2964894ed892b787f355cb/href">https://medium.com/media/d0706d367a2964894ed892b787f355cb/href</a></iframe><p>Here happens the same that the other Dockerfile.</p><h4>File: “todolist-reactjs-example/docker-compose.yml”</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba059577b6bb7d7e07e84a44f568ac01/href">https://medium.com/media/ba059577b6bb7d7e07e84a44f568ac01/href</a></iframe><p>In this file we set what containers we need for our full solution. We are defining the creation of 3 services (containers) “mongodb”, “backend” and “frontend”.</p><p><strong>Mongodb: </strong>will use the image “mongo” and will expose the container port 27017 as the port 27017 in the host machine.</p><p><strong>Backend</strong>: will use the image defined in the “Dockerfile” that exists in the dir “./node-backend/” (build option). Also, will expose the port 6200 in the host machine. The app folder (defined in the Dockerfile as the Workdir) will be “./node-backend” in our machine (volume option).</p><p><strong>Frontend</strong>: will use the image defined in the “Dockerfile” that exists in the dir “./node-frontend/” (build option). Also, will expose the port 3000 in the host machine. The app folder (defined in the Dockerfile as the Workdir) will be “./node-frontend” in our machine (volume option).</p><p>The option “depends_on” indicates that the container will be loaded after that service. The execution will be like this:</p><p>Mongodb-&gt;Backend-&gt;Frontend</p><h3>Execute the services</h3><p>Now that we have all configured, build the images:</p><pre>sudo docker-compose build</pre><p>This will download the images and will execute the commands of the Dockerfile. It can take a few minutes, be patient :)</p><p>When the Build finishes, we can launch our services:</p><pre>sudo docker-compose up</pre><p>Now you have the services running and ready to code our fascinating Todo List app!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FzcCGBRQshGdt6%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FzcCGBRQshGdt6%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FzcCGBRQshGdt6%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="279" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bdf143d44d8bcc626b676e93ed94498/href">https://medium.com/media/8bdf143d44d8bcc626b676e93ed94498/href</a></iframe><p>Happy Coding!</p><p>Gonzalo.</p><h3>NEXT</h3><h4><a href="https://medium.com/codebase/mern-ep02-developing-the-back-end-with-mongodb-nodejs-and-express-556a6748b550">MERN EP02: Developing the Back-End with MongoDB, NodeJS and Express</a></h4><h3>PREVIOUS</h3><h4><a href="https://medium.com/codebase/series-mern-from-scratch-to-a-robust-solution-1af15204e281">(Series) MERN from scratch to a robust solution</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bb0b6e4d464" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/mern-ep01-setting-up-a-development-environment-with-docker-1bb0b6e4d464">MERN EP01: Setting up a development environment with Docker</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Series) MERN from scratch to a robust solution]]></title>
            <link>https://medium.com/codebase/series-mern-from-scratch-to-a-robust-solution-1af15204e281?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/1af15204e281</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[mern]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Fri, 21 Jul 2017 03:22:51 GMT</pubDate>
            <atom:updated>2017-07-28T04:05:22.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07rQdVTc067ZFp2VYW7jPg.png" /></figure><p>In this series we are going to build an example MERN project (Mongodb, Express, ReactJS, NodeJS). We are going to start with a very simple project and escalate it to a robust productive solution.</p><h3>The Project</h3><p>Personally, I like to start things in a very minimalist way, specially with tutorials that people will read to start a new stack of development or technology. So, we are going to work with a typical basic example project, a <strong>Task Manager (or To Do List)</strong>. Don’t get anxious thinking that the project is too small or boring, we need simple business rules to focus in the development evolution of the complexity of this solution.</p><p>The whole idea is to start small and iterate over this project, adding complexity and learning all the characteristics of a MERN stack solution that we can take to a productive/real world environment.</p><p>What we want to explore in each iteration? let’s make a simple glossary:</p><h3>Glossary</h3><ul><li><a href="https://medium.com/codebase/mern-ep01-setting-up-a-development-environment-with-docker-1bb0b6e4d464">MERN EP01: Setting up a development environment with Docker.</a></li><li><a href="https://medium.com/codebase/mern-ep02-developing-the-back-end-with-mongodb-nodejs-and-express-556a6748b550">MERN EP02: Developing the Back-End with MongoDB, NodeJS and Express</a></li><li><a href="https://medium.com/codebase/mern-ep03-developing-the-front-end-with-nodejs-reactjs-and-bootstrap-3-eda5aba8f8d6">MERN EP03: Developing the Front-End with NodeJS, ReactJS and Bootstrap 3</a></li><li>MERN EP04: Sharing components states with Redux</li><li>MERN EP05: User Authentication &amp; API Security</li><li>MERN EP06: Production Environment</li></ul><p>I will try to post as early I can and with working examples obviously that I’ll leave in my GitHub profile.</p><h3>NEXT</h3><h4><a href="https://medium.com/codebase/mern-ep01-setting-up-a-development-environment-with-docker-1bb0b6e4d464">MERN EP01: Setting up a development environment with Docker</a></h4><p>(Or first relax and enjoy this GIF of a happy dog with his HotDog)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1LweXxLwVT0J2%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1LweXxLwVT0J2%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F1LweXxLwVT0J2%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/05fbc5bb7da501be963a25c852ae177a/href">https://medium.com/media/05fbc5bb7da501be963a25c852ae177a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1af15204e281" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/series-mern-from-scratch-to-a-robust-solution-1af15204e281">(Series) MERN from scratch to a robust solution</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taking Software Refactoring Seriously]]></title>
            <link>https://medium.com/codebase/taking-software-refactoring-seriously-367a8a29fed0?source=rss----91a9ebf7332e---4</link>
            <guid isPermaLink="false">https://medium.com/p/367a8a29fed0</guid>
            <category><![CDATA[developing]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[good-practices]]></category>
            <category><![CDATA[code-smells]]></category>
            <dc:creator><![CDATA[Gonzalo P.]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 03:59:27 GMT</pubDate>
            <atom:updated>2019-09-17T21:03:51.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQNNdYo5EfJ1UEwT6CJULQ.png" /></figure><p>Most of the developers do refactor they software consciously or unconsciously. Maybe, you just rename some class or function thinking that the new name represent in a better way what the code does. Yes, that’s refactoring!.</p><blockquote><strong>Code refactoring</strong> is the process of restructuring existing computer code without changing its funcitonality.</blockquote><p>Obviously, renaming is a very small part of software refactoring . The main objective that this pursue is to improve different aspects of the code, like readability, execution time, find bugs that aren’t detected yet or to “force” the code to follow design patterns and coding conventions defined for the project.</p><p>The key thing here is to apply a big amount of small improvements to the code, where the sum of all these changes generate a great impact on the health and maintainability of the application.</p><h3>The strategy</h3><p>To achieve good refactoring you can follow a very basic strategy or guideline:</p><p>Estimate your work with a timespace for refactoring. For example, if you estimate that you can do some task in 10 hours, reserve 2 hours for just look at the code and make modifications. If you don’t put an amount of time in your estimation, you will never have time to do it.</p><p><strong>Avoid premature optimization</strong>. Just take the feature that you have to develop and make it work without thinking to much in the optimal execution or in the most elegant way (please don’t make a mess here, just don’t over engineer it at first!). Later you will have some time to make it look and run better.</p><p><strong>Early detection</strong>. Most of the time while you are developing you realise that what you coded a few moments ago can be written in some other way. Don’t start over thinking here, write down the idea so you can work on it later. But don’t forget it ;)</p><p><strong>Making the big picture</strong>. Now that the feature is complete, you can debug the application. Compare the finished feature with the requirements and try to find problems. Debug the application and follow the code step by step, put it in different scenarios and take note of all the problems that you can encounter.</p><p><strong>Refactoring!</strong>. Now you that you have the big picture of the feature and have a general idea of what things you can improve, you can start re writing and changing the code. Usually in this case unit test will have your back.</p><h3>How to identify what I need to refactor</h3><p>There are some basic points that you can look in your code:</p><ul><li>Think about what architecture and conventions your team has defined for the project.</li><li>always look to achieve good practices. Start with looking what good practices are easy to apply and then move to more complex ones.</li><li>Brake down functions. Don’t let that they get bigger with the time!</li><li>If you feel that a class have to much responsibilities, divide it. Or maybe just move some functions to other class that is more related to it. (Single responsibility principle)</li><li>Simplify conditions/use switch cases instead of a lot of “if”s.</li><li>Same code in different places? Maybe you can create some abstraction and review your overall design, something may be missing. Usually a few extra classes or entities that can take over a responsibility.</li></ul><h3>Some Tips</h3><ul><li>Make small changes first: Rename variables or functions, break functions or classes in two or more, re order code. Easy stuff!</li><li>Keep it simple, don’t make the code more complex.</li><li>Run unit tests between changes. If you made a ton of changes, executed the application and then you realise that is not working how it supposed and the tests are not passing, you will not know at first what specific change was the one who broke it.</li><li>Clean the code. When you look at the code, test it and you feel good about how it works and looks, you can start erasing commented code, deleting variables and functions that have no references and commenting key parts of the code.</li><li>Don’t be afraid to have more files, classes, interfaces and functions. It’s better than having less ones but difficult to understand.</li><li>Think that the code could be read by others developers. You will always be working with colleagues, not alone. So, think that they need to understand what you are coding and commenting.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*x3AVN-DAvSqwRNMgWiUYqw.png" /><figcaption>Think about this, it’s funny but it will help you to think differently</figcaption></figure><h3>Conclusion</h3><p>This approach to refactoring software is based in my experience, and obviously, it can be improved. Try to start with smalls changes and improve your ability of refactoring with the time. Remember to be constant with this and you will succeed!</p><p>If you think that you have a nice idea that I can add to this article, please let me know in the comments bellow!</p><p>Happy Coding!</p><p>Gonzalo.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=367a8a29fed0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codebase/taking-software-refactoring-seriously-367a8a29fed0">Taking Software Refactoring Seriously</a> was originally published in <a href="https://medium.com/codebase">Codebase</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>