{"_id":"n-backend-generator","_rev":"2-2b169468137078e27a83a7e3a1a242f6","name":"n-backend-generator","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"n-backend-generator","version":"1.0.0","keywords":["cli","nodejs","backend","template","generator","authentication","mongodb","postgresql","typescript","javascript","commonjs","esm","sequelize","mongoose","jwt","boilerplate"],"author":{"name":"Your Name"},"license":"MIT","_id":"n-backend-generator@1.0.0","maintainers":[{"name":"noumanthedeveloper","email":"mnoumankhalid195@gmail.com"}],"homepage":"https://github.com/yourusername/n-backend#readme","bugs":{"url":"https://github.com/yourusername/n-backend/issues"},"bin":{"n-backend":"bin/cli.js","create-n-backend":"bin/cli.js"},"dist":{"shasum":"b47934d3a879dc3db47ca25d92130eaea2112187","tarball":"https://registry.npmjs.org/n-backend-generator/-/n-backend-generator-1.0.0.tgz","fileCount":124,"integrity":"sha512-kmrmPVkeSuoIDKEVb16zKCvDPuzl2waDoicVFQ5bn477+uwboMHwGCyOtAvPzCbvW/j8sqezJQ2Bv1xLfhaVGg==","signatures":[{"sig":"MEYCIQCditQaBuOi6XLtU4WFts3rgyfOSF21ld6NC5daZciq+QIhAL3zwflG2ObN0ysJAaDWRFcIEFJWfFWbh55+b4y7eLSq","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":199687},"main":"index.js","engines":{"node":">=16.0.0"},"gitHead":"ad6fe955b39a443d878f254c152d7c63aaeb4af6","scripts":{"test":"echo \"No tests specified\"","start":"node bin/cli.js","prepublishOnly":"echo \"Publishing n-backend...\""},"_npmUser":{"name":"noumanthedeveloper","email":"mnoumankhalid195@gmail.com"},"repository":{"url":"git+https://github.com/yourusername/n-backend.git","type":"git"},"_npmVersion":"10.9.3","description":"Production-ready Node.js backend template generator with multiple configuration options (JS/TS, CommonJS/ESM, MongoDB/PostgreSQL)","directories":{},"_nodeVersion":"22.18.0","dependencies":{"chalk":"^4.1.2","fs-extra":"^11.1.1","inquirer":"^9.2.12","commander":"^11.1.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/n-backend-generator_1.0.0_1769323818933_0.8667667792137672","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"n-backend-generator","version":"1.0.1","description":"Production-ready Node.js backend template generator with multiple configuration options (JS/TS, CommonJS/ESM, MongoDB/PostgreSQL)","main":"index.js","bin":{"n-backend":"bin/cli.js","create-n-backend":"bin/cli.js"},"scripts":{"start":"node bin/cli.js","test":"echo \"No tests specified\"","prepublishOnly":"echo \"Publishing n-backend...\""},"keywords":["cli","nodejs","backend","template","generator","authentication","mongodb","postgresql","typescript","javascript","commonjs","esm","sequelize","mongoose","jwt","boilerplate"],"author":{"name":"Nouman The Developer"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/nouman475/n-backend.git"},"homepage":"https://github.com/nouman475/n-backend#readme","bugs":{"url":"https://github.com/nouman475/n-backend/issues"},"engines":{"node":">=16.0.0"},"dependencies":{"inquirer":"^8.2.6","chalk":"^4.1.2","fs-extra":"^11.1.1","commander":"^11.1.0"},"_id":"n-backend-generator@1.0.1","gitHead":"ad6fe955b39a443d878f254c152d7c63aaeb4af6","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-0EOY66HFwILM7SXxApS9SrPOSx1FUxNVkiNflE0ModmWoXZcUd+5B239dqnCVfwPZdAhaH3UK5C12tOiBw8B5A==","shasum":"ad676cdd29cb33a5763abf4a99677ffb629cb13a","tarball":"https://registry.npmjs.org/n-backend-generator/-/n-backend-generator-1.0.1.tgz","fileCount":124,"unpackedSize":199609,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICRUW04Lg7MnuQWteYeEKl//M82jKj/OwMuOkmAKAJr6AiEApnQkiH4XoIw7Y0gRKs2WO3sWrqyMjQ3oWSGlYK8mgeM="}]},"_npmUser":{"name":"noumanthedeveloper","email":"mnoumankhalid195@gmail.com"},"directories":{},"maintainers":[{"name":"noumanthedeveloper","email":"mnoumankhalid195@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/n-backend-generator_1.0.1_1769324589277_0.9584480154193542"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-25T06:50:18.932Z","modified":"2026-01-25T07:03:09.563Z","1.0.0":"2026-01-25T06:50:19.092Z","1.0.1":"2026-01-25T07:03:09.440Z"},"bugs":{"url":"https://github.com/nouman475/n-backend/issues"},"author":{"name":"Nouman The Developer"},"license":"MIT","homepage":"https://github.com/nouman475/n-backend#readme","keywords":["cli","nodejs","backend","template","generator","authentication","mongodb","postgresql","typescript","javascript","commonjs","esm","sequelize","mongoose","jwt","boilerplate"],"repository":{"type":"git","url":"git+https://github.com/nouman475/n-backend.git"},"description":"Production-ready Node.js backend template generator with multiple configuration options (JS/TS, CommonJS/ESM, MongoDB/PostgreSQL)","maintainers":[{"name":"noumanthedeveloper","email":"mnoumankhalid195@gmail.com"}],"readme":"# n-backend-generator\n\n🚀 Production-ready Node.js backend template generator with multiple configuration options.\n\n## Features\n\n- **Multiple Language Support**: JavaScript or TypeScript\n- **Module Systems**: CommonJS or ES Modules\n- **Database Options**: MongoDB (Mongoose) or PostgreSQL (Sequelize)\n- **Authentication**: JWT with access/refresh tokens\n- **Two-Factor Authentication**: TOTP-based 2FA support\n- **Security**: Helmet, CORS, input validation\n- **Logging**: Winston logger with configurable levels\n- **Development**: Hot reload with nodemon/ts-node-dev\n- **Production Ready**: Error handling, validation, clean architecture\n\n## Quick Start\n\n```bash\n# Install globally\nnpm install -g n-backend-generator\n\n# Or use npx (recommended)\nnpx n-backend-generator my-awesome-backend\n\n# Short command\nnpx n-backend my-awesome-backend\n```\n\n## Configuration Options\n\nThe CLI will prompt you to choose:\n\n1. **Project Name**: Your backend project name\n2. **Language**: JavaScript or TypeScript\n3. **Module System**: CommonJS or ES Modules\n4. **Database**: MongoDB (Mongoose) or PostgreSQL (Sequelize)\n5. **Authentication**: Include JWT authentication system\n6. **Logging**: Include Winston logging system\n7. **Two-Factor Auth**: Include TOTP-based 2FA\n\n## Generated Templates\n\nBased on your choices, one of 8 optimized templates will be generated:\n\n- `js-commonjs-mongodb` - JavaScript + CommonJS + MongoDB\n- `js-commonjs-postgresql` - JavaScript + CommonJS + PostgreSQL\n- `js-esm-mongodb` - JavaScript + ES Modules + MongoDB\n- `js-esm-postgresql` - JavaScript + ES Modules + PostgreSQL\n- `ts-commonjs-mongodb` - TypeScript + CommonJS + MongoDB\n- `ts-commonjs-postgresql` - TypeScript + CommonJS + PostgreSQL\n- `ts-esm-mongodb` - TypeScript + ES Modules + MongoDB\n- `ts-esm-postgresql` - TypeScript + ES Modules + PostgreSQL\n\n## Project Structure\n\n```\nyour-project/\n├── src/\n│   ├── controllers/        # Request handlers\n│   │   ├── user/          # User-related controllers\n│   │   └── admin/         # Admin-related controllers\n│   ├── middlewares/       # Custom middleware\n│   ├── models/           # Database models\n│   ├── routes/           # API routes\n│   │   ├── user/         # User routes\n│   │   └── admin/        # Admin routes\n│   ├── services/         # Business logic\n│   │   ├── auth/         # Authentication services\n│   │   └── general/      # General services\n│   ├── helpers/          # Helper functions\n│   │   ├── input/        # Input validation & DTOs\n│   │   └── output/       # Response formatting\n│   ├── utils/            # Utilities\n│   ├── db/              # Database connection\n│   └── index.ts/js      # Entry point\n├── .env.example         # Environment variables template\n├── .gitignore          # Git ignore rules\n├── package.json        # Dependencies and scripts\n├── README.md           # Project documentation\n└── tsconfig.json       # TypeScript config (TS projects only)\n```\n\n## API Endpoints\n\n### Authentication\n- `POST /api/auth/register` - Register new user\n- `POST /api/auth/login` - Login user\n- `POST /api/auth/refresh` - Refresh access token\n- `POST /api/auth/logout` - Logout user\n\n### Two-Factor Authentication (if enabled)\n- `POST /api/auth/2fa/setup` - Setup 2FA\n- `POST /api/auth/2fa/verify` - Verify 2FA token\n- `POST /api/auth/2fa/disable` - Disable 2FA\n\n## Environment Variables\n\nThe generated project includes a comprehensive `.env.example` file with all necessary configuration options:\n\n```env\n# Server Configuration\nPORT=5000\nNODE_ENV=development\nCORS_ORIGIN=http://localhost:3000\n\n# Database (MongoDB)\nCONNECTION_STRING=mongodb://localhost:27017/your-project\n\n# Database (PostgreSQL)\nDATABASE_URL=postgresql://username:password@localhost:5432/your-project\n\n# JWT Configuration\nJWT_ACCESS_SECRET=your_super_secret_access_key\nJWT_REFRESH_SECRET=your_super_secret_refresh_key\nACCESS_TOKEN_EXPIRY=15m\nREFRESH_TOKEN_EXPIRY=7d\n\n# Logging Configuration\nENABLE_LOGGING=true\nLOG_LEVEL=info\nSAVE_LOGS_TO_DB=false\n\n# Two-Factor Authentication\nTWO_FA_SERVICE_NAME=Your Service\nTWO_FA_ISSUER=Your Company\n```\n\n## Getting Started with Generated Project\n\n1. **Install dependencies:**\n   ```bash\n   cd your-project\n   npm install\n   ```\n\n2. **Setup environment:**\n   ```bash\n   cp .env.example .env\n   # Edit .env with your configuration\n   ```\n\n3. **Database setup:**\n   \n   **For MongoDB:**\n   ```bash\n   # Make sure MongoDB is running\n   # Update CONNECTION_STRING in .env if needed\n   ```\n   \n   **For PostgreSQL:**\n   ```bash\n   # Create database\n   createdb your-project\n   \n   # Update DATABASE_URL in .env\n   DATABASE_URL=postgresql://username:password@localhost:5432/your-project\n   ```\n\n4. **Start development server:**\n   ```bash\n   npm run dev\n   ```\n\n5. **Build for production (TypeScript projects):**\n   ```bash\n   npm run build\n   npm start\n   ```\n\n## Features Included\n\n### 🔐 Authentication System\n- User registration and login\n- JWT access and refresh tokens\n- Password hashing with bcrypt\n- Role-based access control (user/admin)\n- Account activation/deactivation\n\n### 🛡️ Two-Factor Authentication\n- TOTP-based 2FA using speakeasy\n- QR code generation for easy setup\n- Backup codes support\n- Easy enable/disable functionality\n\n### 🗄️ Database Integration\n- **MongoDB**: Mongoose ODM with schema validation\n- **PostgreSQL**: Sequelize ORM with migrations support\n- Connection pooling and error handling\n- Model relationships and associations\n\n### 🔒 Security Features\n- Helmet for security headers\n- CORS configuration\n- Input validation and sanitization\n- SQL injection prevention\n- XSS protection\n\n### 📝 Logging System\n- Winston logger with multiple transports\n- Configurable log levels\n- File and console logging\n- Request logging with Morgan\n\n### 🏗️ Clean Architecture\n- Separation of concerns\n- Controller-Service-Model pattern\n- Middleware for cross-cutting concerns\n- Helper functions and utilities\n- DTO pattern for data validation\n\n## Development Scripts\n\n- `npm run dev` - Start development server with hot reload\n- `npm run build` - Build TypeScript project (TS only)\n- `npm start` - Start production server\n- `npm test` - Run tests (placeholder)\n\n## Requirements\n\n- Node.js >= 16.0.0\n- npm or yarn\n- MongoDB or PostgreSQL (depending on choice)\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nIf you encounter any issues or have questions:\n\n1. Check the [Issues](https://github.com/nouman475/n-backend/issues) page\n2. Create a new issue with detailed information\n\n## Changelog\n\n### v1.0.0\n- Initial release\n- Support for 8 different template combinations\n- JWT authentication with 2FA\n- MongoDB and PostgreSQL support\n- TypeScript and JavaScript support\n- CommonJS and ES Modules support\n\n---\n\nMade with ❤️ by [Nouman The Developer](https://nouman.innovrah.com)\n\n**Star ⭐ this repo if you find it helpful!**","readmeFilename":"readme.md"}