Stop repeating work and Start coding your express API 🚀
Tags: node, express, npm, api
Published: 2020-07-14 17:54:03

### Too much wasted time 🙁
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.👨‍💻

### the Solution 🎉
To solve this problem, I started to work on a package called [new-express-app](https://www.npmjs.com/package/new-express-app) 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 [Inquirer.js package](https://www.npmjs.com/package/inquirer) to ask the user a series of questions about his needs. and here is the questions:
- Enter Project Name:

- Enter version:
- Enter description:
- Enter author name:
- Want to initialize git?
- Want to install dotEnv?
- Want to install database driver?
- Want to initialize eslint/prettier?

the first 4 questions to create the <code>package.json</code> file and the rest to determine which dependencies/devdependencies to install. the package installs some dependencies by default which are:
- [Express](https://www.npmjs.com/package/express)
- [CORS](https://www.npmjs.com/package/cors)
- [NodeMon](https://www.npmjs.com/package/nodemon)(devdependency)

and you can optionally add these dependencies:
- [dotEnv](https://www.npmjs.com/package/dotenv)
- [mongodb](https://www.npmjs.com/package/mongodb)
- [mongoose](https://www.npmjs.com/package/mongoose)
- [eslint](https://www.npmjs.com/package/eslint)(devdependency)
- [prettier](https://www.npmjs.com/package/prettier)(devdependency)

the package uses the <code>child process exec</code> 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 [GitHub repository](https://github.com/uptotec/new-express-app) to see the created folder structure and the files content.

### let's some up 😊
1. Install [new-express-app](https://www.npmjs.com/package/new-express-app) globally.
```bash
npm i -g new-express-app
```
2. Answer the questions
![Imgur](https://i.imgur.com/yYIABLR.png)
3. You are ready to change the world.💪
![Imgur](https://i.imgur.com/DER2jdz.png)

Hope you like it and if you have any ideas to improve please, leave it in the comments 😀 .

### Have time to help? 🤝
If you like the idea and you have the time to help feel free to go to the [GitHub repository](https://github.com/uptotec/new-express-app) and add the functionality that you want.