create-node-app-cli
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

create-node-app-cli

create-node-app-cli is a powerful CLI tool that helps developers quickly scaffold a Node.js project with integrated database configuration, ORM setup, and optional TypeScript support. The tool also includes support for popular frameworks such as Express, Fastify, and Nest, as well as built-in Swagger documentation configuration for API development.

Features

  • Framework Choices: Select from popular Node.js frameworks like Express, Fastify, and Nest.
  • Database Integration: Set up MongoDB, PostgreSQL, or MySQL with ease.
  • ORM Support: Automatically configure ORM like Mongoose, Prisma, or DrizzleORM.
  • TypeScript or JavaScript: Choose whether to set up the project with TypeScript or JavaScript.
  • Swagger Documentation: Automatically includes Swagger API docs setup with customizable folder structure for your APIs endpoint and Schemas.
  • Linting and Formatting: Integrated ESLint and Prettier setup for code quality.
  • Environment Configuration: Pre-configured .env sample file for setting up environment variables.
  • Robust Error Handler: Returns a structured JSON response that directly points to where the error originates.
{
  "success": false,
  "message": "Directly pointing to where the error is coming from"
}

Getting Started

Prerequisites

Make sure you have the following installed:

  • Node.js (v14 or higher)
  • npm

Installation

You can install create-node-app-cli via npx:

Usage

npx create-node-app-cli@latest new

After running the command, follow the prompts to configure your project you'll be asked to select: Framework: Express, Fastify, or Nest. Database: MongoDB, PostgreSQL, or MySQL. ORM: Mongoose, Prisma, or DrizzleORM. TypeScript or JavaScript.

Folder Structure

The CLI generates a project with the following folder structure

my-app/
│
├── src/
│   ├── controllers/
│   ├── routes/
│   ├── mails/
│   ├── middleware/
|   |   └── async-error.ts/
|   |   └── error.ts/
│   ├── services/
│   ├── schemas/
│   ├── swagger-docs/
│   │   ├── swagger-api-docs/
|   |   |   ├── sample-api.yaml
│   │   └── swagger-schema-docs/
|   |   |   ├── sample-schema.yaml
│   └── utils/
|   |   ├── db.ts
|   |   ├── error-handler.ts
│   └── app.ts
|   └── server.ts
├── .env.sample
├── .gitignore
├── package.json
├── tsconfig.json (if using TypeScript)
└── README.md

Swagger Documentation

The project includes built-in Swagger documentation configuration to help you document and visualize your API. By default, the Swagger docs are available at:

    /api-docs

Environment Variables

You can configure your environment by copying the .env.sample file to .env and setting the appropriate values for your project.

    cp .env.sample .env

Available Scripts

Here are some useful npm scripts to help you manage the project:

  • Start the development server:

    npm run dev
  • Build the project:

    npm run build
  • Lint your code:

    npm run lint

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i create-node-app-cli

Weekly Downloads

4

Version

1.1.0

License

MIT

Unpacked Size

79.2 kB

Total Files

7

Last publish

Collaborators

  • munaray