generate-node-structure
v0.1.0
Published
π The Ultimate Node.js & Express Boilerplate. Production-ready REST API generator with PostgreSQL, JWT Auth, Security, Sentry, and more. Start your next project in seconds!
Maintainers
Readme
π Generate Node Structure
The Ultimate Production-Ready Node.js & Express Boilerplate
- Build scalable, secure, and high-performance REST APIs in seconds.
- Stop wasting time on boilerplate code. Focus on building your product.
π Why Choose This Boilerplate?
Starting a new Node.js project often involves setting up the same repetitive structure: Authentication, Database connection, Security headers, Error handling, etc. Generate Node Structure eliminates this hassle by providing a battle-tested, production-ready foundation instantly.
Whether you are building a small MVP or a large-scale enterprise application, this structure scales with you.
β¨ Key Features
| Feature | Description |
| :--- | :--- |
| π Modular Architecture | Clean, organized folder structure designed for scalability and maintainability. |
| π PostgreSQL Ready | Pre-configured with pg for robust and efficient database interactions. |
| π Complete Auth System | JWT-based Authentication: Signup, Login, Logout, Password Reset & Email Verification. |
| π‘ Enterprise Security | Secured with Helmet, CORS, Rate Limiting, and Input Validation (Joi). |
| π Auto Documentation | Integrated API documentation generation with node-api-document. |
| π§ Email Service | Ready-to-use email sending service with Nodemailer and EJS templates. |
| π Real-time Monitoring | Integrated Sentry for tracking errors and performance issues in real-time. |
| π Localization (i18n) | Built-in support for multiple languages using localizify. |
| β‘ High Performance | Optimized query structure, compression, and best practices for speed. |
π Getting Started
Launch your new project in under 30 seconds.
Option 1: The Fastest Way (npx)
Run this command in your terminal where you want to create your project:
npx generate-node-structureOption 2: Global Installation
Install the CLI globally to use it anytime:
npm install -g generate-node-structureThen generate a new project:
create-node-structureπ Project Structure Overview
We follow a clean Model-Service-Controller pattern to keep concerns separated.
.
βββ bin/ # CLI entry point
βββ config/ # Database & App Configuration
βββ enc_dec/ # Encryption & Decryption Utilities
βββ languages/ # Localization (i18n) Files
βββ middleware/ # Custom Express Middleware (Auth, Error handling)
βββ modules/ # API Features (The heart of your app)
β βββ v1/ # Versioned API
β βββ Auth/ # Authentication Module
β βββ User/ # User Management Module
βββ scripts/ # Database initialization & utility scripts
βββ template/ # Project templates
βββ tests/ # Unit & Integration Tests
βββ utils/ # Shared Helper Functions
βββ views/ # Email Templates (EJS)
βββ .env.example # Environment Variables Reference
βββ index.js # App Entry Point
βββ package.json # Dependencies & Scriptsπ Configuration
1. Environment Variables
Rename .env.example to .env and configure your secrets:
cp .env.example .envOpen .env and fill in your details:
- Database Credentials (Host, User, Password, DB Name)
- JWT Secret (For secure token generation)
- Sentry DSN (For error tracking)
- Email Credentials (For sending system emails)
2. Database Setup
Initialize your PostgreSQL database tables with a single command:
npm run db:initπ Available Scripts
| Script | Description |
| :--- | :--- |
| npm start | Starts the production server. |
| npm run dev | Starts the development server with hot-reloading (nodemon). |
| npm test | Runs the test suite using jest. |
| npm run db:init | Creates necessary database tables. |
π Tech Stack
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- Validation: Joi
- Authentication: JWT & Bcrypt.js
- Logging: Sentry
- Documentation: node-api-document
π€ Contributing
We love contributions! If you have ideas for improvements or find a bug, please open an issue or submit a pull request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
π License
Distributed under the MIT License. See LICENSE for more information.
Made with β€οΈ by Tirth Gaudani
