New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

perfect-node-structure

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfect-node-structure

A Node.js project structure generator

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

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

  • Save the script as index.js in your project directory.
  • Make the script executable:
    chmod +x index.js
    
  • 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.

Keywords

node

FAQs

Package last updated on 25 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts