perfect-node-structure

1.0.3 • Public • Published

Express.js Project Structure Generator

This Node.js script automatically generates a standardized folder structure for an Express.js project. It creates a src directory with essential subdirectories and files commonly used in Express.js applications.

Folder Structure

The script creates the following folder structure:

src/
├── server.js
├── middlewares/
│   ├── joi.validate.js
│   ├── uploads.js
│   └── auth.js
├── config/
│   └── db.config.js
├── routes/
│   └── user.routes.js
├── models/
│   └── user.model.js
├── controllers/
│   └── user/
│       ├── signup.controller.js
│       └── login.controller.js
└── utils/

Usage

  1. Save the script as index.js in your project directory.
  2. Make the script executable:
    chmod +x index.js
    
  3. Run the script:
    ./index.js
    

Functionality

  • The script creates the main src directory if it doesn't exist.
  • It then creates subdirectories for middlewares, config, routes, models, controllers, and utils.
  • Specific files are created in each subdirectory as needed.
  • The script checks for existing folders and files to avoid overwriting.
  • Console output provides information about created folders and files.

Customization

You can easily modify the subFolders array and the createFolderStructure function to adjust the folder structure and files created according to your project needs.

Note

The script changes the current working directory to two levels up before creating the folder structure. Ensure you run it from the appropriate location in your project.

Dependencies

This script uses Node.js built-in modules:

  • fs for file system operations
  • path for handling file paths

No additional dependencies are required.

License

This script is provided as-is under the MIT License. Feel free to modify and use it in your projects.

Package Sidebar

Install

npm i perfect-node-structure

Weekly Downloads

7

Version

1.0.3

License

MIT

Unpacked Size

6.32 kB

Total Files

3

Last publish

Collaborators

  • jenish35