JSPM

perfect-node-structure

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q28732F
  • License MIT

A Node.js project structure generator

Package Exports

  • perfect-node-structure
  • perfect-node-structure/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (perfect-node-structure) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.