UNPKG

node-folder-structure

Version:

Generate an Express.js app with 3-layer architecture. Quick start: npx node-folder-structure

57 lines (49 loc) 2.39 kB
## Quick Start (Recommended) ```bash # Create in current directory npx node-folder-structure # Create in new directory npx node-folder-structure my-app ``` ## Project Structure ``` public/temp # Contains static assets like images src/ # Main source code directory ├── config/ # Configuration-related files like db configurations ├── constants/ # Constants like db name and other fixed constraints ├── controllers/ # Contains individual controllers for handling requests │ └── user.controller.js # Controls user-related requests ├── docs/ # Swagger documentation for API endpoints ├── jobs/ # Background jobs or scheduled tasks ├── middlewares/ # Custom Express middlewares ├── loaders/ # Lodash routes and configurations ├── models/ # Database models; ORM files for the data layer │ └── seeders/ # MongoDB custom seeders ├── routes/ # Defines API routes ├── services/ # Contains business logic and service functions │ └── user.service.js # User-related business logic ├── utils/ # Utility classes and functions │ ├── ApiError.js # API error class │ ├── ApiResponse.js # API response class │ ├── asyncHandler.js # Higher order function for error handling │ └── generateToken.js # Access and refresh tokens ├── validators/ # Schema validation functions using AJV ├── app.js # Express app setup └── server.js # Entry point for the application ``` # Node Folder Structure Generator A CLI tool to generate an express app with a 3-layer approach folder structure. ## Installation & Usage You can use this package in two ways: ### Using npx (Recommended) ```bash npx node-folder-structure ``` This will generate a complete Express.js project structure with: - MVC architecture - Middleware setup - Validation middleware - Error handling - Database configuration - Modern 3-layer approach - And more...