UNPKG

nim-nodex-init

Version:

nim-nodex-init is a powerful CLI tool that scaffolds a complete Node.js & Express.js app with your preferred database, ORM, authentication system, and organized folder structure โ€” all in seconds.

187 lines (130 loc) โ€ข 3.98 kB
# ๐Ÿš€ nim-nodex-init **`nim-nodex-init`** is a powerful CLI tool that scaffolds a complete Node.js & Express.js app with your preferred database, ORM, authentication system, and organized folder structure โ€” all in seconds. --- ## ๐Ÿ“ฆ Install & Usage You can use the CLI directly with `npx` (recommended): ```bash npx nim-nodex-init ``` Or install it globally if you prefer: ```bash npm install -g nim-nodex-init ``` Then run it from anywhere with: ```bash nim-nodex-init ``` --- ## โš™๏ธ What It Does When you run: ```bash npx nim-nodex-init ``` It guides you through an interactive setup to: - ๐Ÿท๏ธ Set project name - ๐Ÿ’ป Choose language: JavaScript or TypeScript - ๐Ÿ›ข๏ธ Select a database: MongoDB, MySQL, PostgreSQL, or SQLite - ๐Ÿ”Œ If SQL, choose ORM: Sequelize or Prisma - โš™๏ธ Automatically install dependencies - ๐Ÿ“ Generate a fully structured Express project: - DB configuration - Environment setup - Clean project architecture --- ## ๐Ÿง  Why Use nim-nodex-init? - No need to manually configure Express, database, routes, controllers, or middleware. - Great for quickly bootstrapping REST APIs. - Flexible with JS or TS. - Includes modern best practices: JWT, bcrypt, input validation. --- ## ๐Ÿ› ๏ธ Tech Stack - **Node.js** - **Inquirer.js** โ€” CLI prompts - **Chalk** โ€” Terminal output styling - **Execa** โ€” Shell command execution - **fs / path** โ€” File generation - **dotenv** โ€” Environment management --- ## ๐Ÿ’ก How It Works When you run the command, `nim-nodex-init` will: 1. Prompt for: - Project name - Language: JavaScript or TypeScript - Database (MongoDB, MySQL, PostgreSQL, SQLite) - ORM (Sequelize or Prisma) 2. Create a project folder with: - Configured `server.js` or `server.ts` - Connected `.env` file - Installed dependencies - JWT auth (register & login) - Folder structure: routes, models, controllers, config 3. Add sample user model and controller 4. Set up static `public` directory --- ## โœจ Example CLI Interaction ```bash $ npx nim-nodex-init ๐Ÿ› ๏ธ Welcome to nim-nodex-init! โœ” Project name: my-api โœ” Use JavaScript or TypeScript? โ†’ JavaScript โœ” Choose a database โ†’ MySQL โœ” Choose ORM โ†’ Sequelize โœ” Add register/login logic with real hashing? โ†’ Yes ๐Ÿ“ฆ Installing packages... ๐Ÿ“ Creating folders and boilerplate... โœ… Setup complete! ๐Ÿ‘‰ cd my-api ๐Ÿ‘‰ npm run dev ``` --- ## ๐Ÿ“‚ Generated Project Structure ```bash your-project/ โ”œโ”€โ”€ server.js # Entry point โ”œโ”€โ”€ .env # Environment variables (DB_URI, PORT, BASE_URL) โ”œโ”€โ”€ public/ # Static assets โ”œโ”€โ”€ config/ โ”‚ โ””โ”€โ”€ db.js # Database connection logic โ”œโ”€โ”€ routes/ โ”‚ โ””โ”€โ”€ AuthRoute.js # /auth routes โ”œโ”€โ”€ controllers/ โ”‚ โ””โ”€โ”€ AuthController.js # Register & Login logic โ”œโ”€โ”€ models/ โ”‚ โ””โ”€โ”€ User.js # User model based on DB/ORM โ”œโ”€โ”€ package.json # Scripts and metadata ``` --- ## ๐Ÿ” Auth Features Includes: - `/auth/register` โ€” Create new user with hashed password - `/auth/login` โ€” Authenticate user and return JWT --- ## ๐Ÿงช Scripts ```bash npm start # Run app with node npm run dev # Run app with nodemon (auto-reloads) ``` --- ## ๐Ÿ“ Environment File (.env) ```env PORT=5000 BASE_URL=http://localhost:5000 DB_URI=mysql://username:password@localhost/dbname JWT_SECRET=your_jwt_secret_here ``` --- ## ๐Ÿง  Future Improvements - Add CLI flags for non-interactive usage - Optional frontend boilerplate integration - Testing setup with Jest or Vitest - Docker support --- ## ๐Ÿ“ฆ Contributing Feel free to fork, improve, and make PRs โ€” your contributions are welcome! --- ## ๐Ÿ™ Credits Built by **ZaYn Miraj** CLI Creator: [@zaynmiraj](https://www.zaynmiraj.com) --- ## ๐Ÿ License MIT ยฉ 2025 [Zayn Miraj](https://github.com/zaynmiraj)