@cybergenius/node-artisan
v1.0.9
Published
CLI for Node.js. Create a new project, controller, model, and more.
Downloads
18
Maintainers
Readme
Node Artisan CLI
A powerful CLI tool for Node.js development that helps you scaffold projects and components quickly.
Features
- 🚀 Quick project scaffolding
- 🎮 Generate controllers, models, and routes
- 🛠️ Built-in authentication setup
- 📦 Modern project structure
- ⚡ Express.js integration
- 🗄️ MongoDB/Mongoose support
- 🧪 Testing utilities
- 🔄 Database migrations and seeders
- ✨ Middleware generation
- 📝 Validation helpers
- ⚙️ Configuration management
- 📨 Job/Queue management
Installation
Method 1: Global Installation (CLI Tool)
npm install -g @cybergenius/node-artisanWith global installation, you can use the CLI commands anywhere:
# Create a new Node.js project
node-artisan new my-app
# Generate components within your project
node-artisan make:controller UserController
node-artisan make:model UserMethod 2: Project Dependency
npm install @cybergenius/node-artisanWhen installed as a dependency, you can use it in your code:
import { app, connectDB, initServer } from '@cybergenius/node-artisan';
// Initialize the server
await connectDB();
initServer();Available Commands
Project Creation
# Create a new Node.js project
node-artisan new <project-name>
# Start development server
node-artisan serve
node-artisan serve --port 3000Models, Controllers & Routes
# Generate a model
node-artisan make:model User
node-artisan make:model User --resource # With controller and routes
node-artisan make:model User --rc # Shorthand for --resource
# Generate a controller
node-artisan make:controller UserController
node-artisan make:controller UserController --resource # With CRUD methods
# Generate a route
node-artisan make:route users
node-artisan make:route users --resource # With CRUD endpointsDatabase Operations
# Generate a migration
node-artisan make:migration create_users_table
# Generate a seeder
node-artisan make:seeder UserSeeder
# Run seeders
node-artisan db:seedMiddleware & Validation
# Generate middleware
node-artisan make:middleware Auth
node-artisan make:middleware RateLimit
# Generate validator
node-artisan make:validator UserTesting
# Generate tests
node-artisan make:test UserTest
node-artisan make:test UserTest --unit # Unit test
node-artisan make:test UserTest --feature # Feature testConfiguration
# Generate config file
node-artisan make:config database
node-artisan make:config cache
# List all config files
node-artisan config:listJobs & Queue
# Generate jobs
node-artisan make:job SendEmail
node-artisan make:job ProcessPayment --sync # Synchronous job
node-artisan make:job ImportData --async # Asynchronous jobEnvironment
# Generate .env file
node-artisan env:generateEnvironment Configuration
Create a .env file in your project directory or .node-artisan.env in your home directory:
MONGODB_URI=your_mongodb_connection_string
PORT=3000
JWT_SECRET=your_jwt_secretProject Structure
my-project/
├── controllers/ # Request handlers
├── models/ # Database models
├── routes/ # API routes
├── middleware/ # Custom middleware
├── config/ # Configuration files
├── validators/ # Request validation
└── jobs/ # Background jobs
├── tests/
│ ├── unit/ # Unit tests
│ └── feature/ # Feature tests
├── database/
│ ├── migrations/ # Database migrations
│ └── seeders/ # Database seeders
├── .env # Environment variables
└── server.js # Application entry pointLicense
ISC License
Author
Emmanuel Kolawole
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or need help, please file an issue on the GitHub repository.
