DEV Community

Cover image for How Repeated Configuration Led Me to Build a Node.js CLI
Abdulsalam Sa'ad
Abdulsalam Sa'ad

Posted on

How Repeated Configuration Led Me to Build a Node.js CLI

If you're a Node.js developer, you've probably noticed one common pain point: repeated project configuration. It’s always the same setup — TypeScript, database connections, Swagger docs, and more.

As a developer who loves to streamline my workflow, I realized that instead of repeating this configuration every single time, it would make sense to create a CLI to automate the process. Thus, Create Node App CLI was born — a CLI that scaffolds a Node.js project with optional configurations for frameworks, databases, ORMs, TypeScript support, and Swagger docs.

The Problem: Repetition in Project Setup

Recently, I started using TypeScript to build my Node.js APIs, and I kept running into the same issue: every time I started a new project, I had to spend valuable time setting up the same configuration files.

Every new project meant going through the process of:

  • Setting up TypeScript.
  • Integrating a database (MongoDB, PostgreSQL, or MySQL).
  • Choosing and configuring an ORM like Mongoose or Prisma.
  • Configuring Swagger for API documentation.
  • Handling environment variables.

This was getting repetitive and frustrating. It was taking time away from actually building the core features of my applications.

The Solution: A CLI to Automate the Setup

I thought, “What if I could create a tool that automates all of this?” That’s how Create Node App CLI came to life.

This CLI allows developers to scaffold a new Node.js project with:

  • Your choice of framework: Express, Fastify, or Nest.
  • Your choice of database: MongoDB, PostgreSQL, or MySQL.
  • Integration with popular ORMs like Mongoose or Prisma.
  • Support for TypeScript or JavaScript.
  • Automatic setup of Swagger documentation for your APIs.

With a single command, developers can create a new project, select their preferences, and have all the necessary configurations in place, including folder structure, linting, and environment variables.

*Features of Create Node App CLI *

  1. Framework Options: Choose between Express, Fastify, or Nest based on your project’s needs.

  2. Database Support: Seamless integration with databases like MongoDB, PostgreSQL, or MySQL — complete with the option to choose ORMs like Mongoose, Prisma, or DrizzleORM.

  3. TypeScript or JavaScript: You get the option to scaffold your project with either TypeScript or JavaScript, saving time on setting up the necessary configurations.

  4. Swagger Documentation: Automatically generates Swagger documentation configuration folders and file for your APIs, so you can focus on building on it rather than manually setting it up.

How to Use It

Install via npx:



npx create-node-app-cli@latest new 


Enter fullscreen mode Exit fullscreen mode

Once you run the command, the CLI will prompt you to choose your framework, database, ORM, and whether to use TypeScript or JavaScript.

Example:



npx create-node-app-cli@latest new my-api 


Enter fullscreen mode Exit fullscreen mode

This command will set up a fully functional Node.js project, configured with your chosen options.

Let’s Build Together! Contributions are Welcome

This project is open source, and I believe that it can grow with the help of the developer community. There’s still so much we can add-new features-more framework support-database integrations, and more. So, I’m inviting you to contribute.

You can contribute by:

  • Submitting pull requests with new features or bug fixes.
  • Opening issues for suggestions and improvements.
  • Sharing feedback on how to make it better!

🔗 GitHub Repository: Create Node App CLI on GitHub
I look forward to building this out with the community. Let’s streamline Node.js project creation for everyone! 💻

Conclusion

The journey of building this CLI has been about solving my own pain points, but now I want to share this solution with the broader developer community. I hope you find this tool helpful, and I’m excited to see what the community contributes to it.

🔗 npm: Create Node App CLI on npm

🔗 GitHub: Create Node App CLI on GitHub

Top comments (0)