<?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>Forem: Mahmoud Ashraf Mahmoud</title>
    <description>The latest articles on Forem by Mahmoud Ashraf Mahmoud (@uptotec).</description>
    <link>https://forem.com/uptotec</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%2F421318%2Fa37896cb-a6e8-44a4-a4ad-cbd4c739afde.jpeg</url>
      <title>Forem: Mahmoud Ashraf Mahmoud</title>
      <link>https://forem.com/uptotec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/uptotec"/>
    <language>en</language>
    <item>
      <title>Stop repeating work and Start coding your express API 🚀</title>
      <dc:creator>Mahmoud Ashraf Mahmoud</dc:creator>
      <pubDate>Tue, 14 Jul 2020 17:54:03 +0000</pubDate>
      <link>https://forem.com/uptotec/stop-repeating-work-and-start-coding-your-express-api-39l1</link>
      <guid>https://forem.com/uptotec/stop-repeating-work-and-start-coding-your-express-api-39l1</guid>
      <description>&lt;h3&gt;
  
  
  Too much wasted time 🙁
&lt;/h3&gt;

&lt;p&gt;Think about every time you started a new Express API. you start by creating a new folder, initialize npm, installing the essential dependencies one by one, creating the same folder structure with the same files with the same default code, and making a ton of config files for eslint, prettier, git, etc. All of that and you didn't even start writing any code for your project. setting up express project takes a lot of time upfront and it gets more frustrating if you are working with microservices as you will go by these same steps more and more. I tried to deal with this problem by creating a pre-configured project in a repository and clone it every time I wanted to create a new project, but I found myself still editing it every time to meet the requirements of the new project. I took some time doing this then I realize that this isn't an ideal solution. So, I decided to do what's called a programmer move and automate the process.👨‍💻&lt;/p&gt;

&lt;h3&gt;
  
  
  the Solution 🎉
&lt;/h3&gt;

&lt;p&gt;To solve this problem, I started to work on a package called &lt;a href="https://www.npmjs.com/package/new-express-app"&gt;new-express-app&lt;/a&gt; to create ready to code express apps with simple cli command. the package has to be different from the repository solution as it should create the project with my exact needs no more no less. So, I used the &lt;a href="https://www.npmjs.com/package/inquirer"&gt;Inquirer.js package&lt;/a&gt; to ask the user a series of questions about his needs. and here is the questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Enter Project Name:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter version:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter description:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter author name:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Want to initialize git?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Want to install dotEnv?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Want to install database driver?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Want to initialize eslint/prettier?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the first 4 questions to create the &lt;code&gt;package.json&lt;/code&gt; file and the rest to determine which dependencies/devdependencies to install. the package installs some dependencies by default which are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/express"&gt;Express&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/cors"&gt;CORS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/nodemon"&gt;NodeMon&lt;/a&gt;(devdependency)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and you can optionally add these dependencies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/dotenv"&gt;dotEnv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/mongodb"&gt;mongodb&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/mongoose"&gt;mongoose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/eslint"&gt;eslint&lt;/a&gt;(devdependency)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/prettier"&gt;prettier&lt;/a&gt;(devdependency)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the package uses the &lt;code&gt;child process exec&lt;/code&gt; to initialize git, install dependencies and even open vscode for you. also it adds all the config files for eslint, prettier, dotenv and git. and the required code for database connection is also added so you only need to add your connection string and start coding immediately 🚀. you can refer to the &lt;a href="https://github.com/uptotec/new-express-app"&gt;GitHub repository&lt;/a&gt; to see the created folder structure and the files content.&lt;/p&gt;

&lt;h3&gt;
  
  
  let's some up 😊
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://www.npmjs.com/package/new-express-app"&gt;new-express-app&lt;/a&gt; globally.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-g&lt;/span&gt; new-express-app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Answer the questions
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZCc06Kff--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/yYIABLR.png" alt="Imgur"&gt;
&lt;/li&gt;
&lt;li&gt;You are ready to change the world.💪
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4GSzs8Eb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/DER2jdz.png" alt="Imgur"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hope you like it and if you have any ideas to improve please, leave it in the comments 😀 .&lt;/p&gt;

&lt;h3&gt;
  
  
  Have time to help? 🤝
&lt;/h3&gt;

&lt;p&gt;If you like the idea and you have the time to help feel free to go to the &lt;a href="https://github.com/uptotec/new-express-app"&gt;GitHub repository&lt;/a&gt; and add the functionality that you want.&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>npm</category>
      <category>api</category>
    </item>
  </channel>
</rss>
