1.0.1 • Published 10 months ago

backend-boilerplate-generator v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

Backend Boilerplate Generator

Overview

The backend-boilerplate-generator is a CLI tool that automatically generates a basic backend project structure with pre-configured files and folders such as controllers, models, routes, middlewares, and db. This package is intended to save time by eliminating the need to manually create these files and directories whenever you start a new backend development project.

Features

  • Automatically generates a backend project structure.
  • Creates essential folders like controllers, models, routes, middlewares, db, etc.
  • Generates basic app.js, index.js, and other boilerplate files with starter code.
  • Speeds up backend development setup for new projects.

Installation

To use this package globally, you can install it via NPM:

npm install -g backend-boilerplate-generator

Alternatively, you can install it locally to use it within a single project:

npm install backend-boilerplate-generator

Usage

Once the package is installed globally, you can use the CLI command create-backend to generate a new backend project structure.

Example:

To generate a new backend project structure in the current directory, run the following command:

create-backend <project-name>

This will create a new folder with the following structure inside the <project-name> directory:

<project-name>/
├── public/
│   └── temp/
│       └── .gitkeep
├── src/
│   ├── controllers/
│   ├── db/
│   ├── middlewares/
│   ├── models/
│   ├── routes/
│   ├── app.js
│   ├── constants.js
│   └── index.js
├── .env
├── .env.example
├── .gitignore
├── package.json
└── README.md

Folder & File Descriptions

  • public/temp/.gitkeep: Keeps the public directory in the repo.
  • src/controllers/: Contains the application's controllers.
  • src/db/: Holds the database connection setup files.
  • src/middlewares/: Stores any middleware for the app.
  • src/models/: Contains models for the database (e.g., Mongoose models).
  • src/routes/: Contains route definitions.
  • src/app.js: Main application file for initializing the Express server.
  • src/index.js: Entry point to start the server.
  • src/constants.js: File for storing global constants.
  • .env: Environment variables (should be set based on .env.example).
  • .gitignore: Defines files to be ignored by git (e.g., node_modules/, .env).
  • README.md: Documentation for the project.

Example Workflow

  1. Install the package globally:

    npm install -g backend-boilerplate-generator
  2. Navigate to the directory where you want to create your project and run:

    create-backend my-new-backend
  3. The project will be created in the folder my-new-backend with a boilerplate structure.

  4. Install dependencies by running npm install inside the created project folder.

Contributing

Contributions are welcome! If you find any issues or want to add new features, feel free to open an issue or submit a pull request.

License

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

1.0.1

10 months ago

1.0.0

10 months ago