xacos
v1.0.12
Published
Professional backend scaffolding CLI - Laravel Artisan for Node.js
Maintainers
Readme
📦 Xacos CLI
Backend scaffolding CLI - for Node.js
Xacos is a powerful CLI tool that helps you scaffold production-ready Node.js backend projects with Express.js, following industry best practices and professional folder structures.
🚀 Installation
Global Installation (Recommended)
npm install -g xacosUse without installation
npx xacos <command>📖 Commands
init <name> - Initialize a new project
Creates a new backend project with a professional folder structure.
npx xacos init my-backend --js --mongodb
npx xacos init my-backend --ts --prismaOptions:
--js- Use JavaScript (default)--ts- Use TypeScript--mongodb- Setup MongoDB with Mongoose--prisma- Setup Prisma ORM--redis- Include Redis client--ws- Include native WebSocket--socket.io- Include Socket.io--docker- Include Docker files--git-action- Include GitHub Actions CI/CD
Example:
npx xacos init api-server --ts --prisma --redis --dockeradd <name> - Add a new module
Creates a complete module with controller, service, model, and routes.
npx xacos add Users
npx xacos add notifications
npx xacos add productsThis command generates:
src/controllers/{name}.controller.jssrc/services/{name}.service.jssrc/models/{name}.model.jssrc/routes/{name}.routes.js
And automatically registers the route in src/routes/index.js.
create:redis - Create Redis utility
Sets up Redis client with helper functions.
npx xacos create:redisCreates src/utils/redis.js with connection, caching helpers, and error handling.
create:prisma - Create Prisma setup
Sets up Prisma ORM with schema and database configuration.
npx xacos create:prismaCreates:
prisma/schema.prismasrc/config/db.js(Prisma client)
create:ws - Create native WebSocket setup
Sets up native WebSocket server.
npx xacos create:wsCreates src/sockets/index.js with WebSocket server configuration.
create:socket.io - Create Socket.io setup
Sets up Socket.io server.
npx xacos create:socket.ioCreates src/sockets/index.js with Socket.io server and room management.
create:message-queue - Create message queue setup
Sets up BullMQ for job processing.
npx xacos create:message-queueCreates src/queues/index.js with example email queue and worker.
create:pub-sub - Create pub/sub setup
Sets up event-driven pub/sub system.
npx xacos create:pub-subCreates:
src/utils/pubsub.js- Event emitter wrappersrc/subscribers/index.js- Example subscribers
make:docker - Create Docker files
Creates Dockerfile and docker-compose.yml.
npx xacos make:dockerCreates:
docker/Dockerfiledocker/docker-compose.yml.dockerignore
Automatically configures services based on your project (MongoDB, Redis, PostgreSQL).
make:git-action - Create GitHub Actions CI/CD
Creates GitHub Actions workflow for CI/CD.
npx xacos make:git-actionCreates .github/workflows/ci.yml with:
- Node.js setup
- Dependency caching
- Linting, testing, building
- Prisma migrations (if using Prisma)
📁 Project Structure
After running init, you'll get:
my-backend/
├── src/
│ ├── app.js # Express app configuration
│ ├── server.js # Server bootstrap
│ ├── config/ # Configuration files
│ │ ├── db.js
│ │ └── env.js
│ ├── routes/ # API routes
│ │ └── index.js
│ ├── controllers/ # Route controllers
│ ├── services/ # Business logic
│ ├── models/ # Data models
│ ├── middlewares/ # Custom middlewares
│ ├── utils/ # Utility functions
│ │ ├── logger.js
│ │ └── response.js
│ ├── sockets/ # WebSocket/Socket.io
│ ├── queues/ # Message queues
│ └── subscribers/ # Event subscribers
├── prisma/ # Prisma schema (if --prisma)
├── docker/ # Docker files (if --docker)
├── .github/workflows/ # CI/CD (if --git-action)
├── .env
├── .env.example
├── .gitignore
├── package.json
├── README.md
└── xacos.json # CLI metadata🎯 Quick Start
Create a new project:
npx xacos init my-api --js --mongodbAdd a module:
cd my-api npx xacos add UsersInstall dependencies:
npm installStart development server:
npm run dev
📝 Example Workflow
# 1. Initialize project
npx xacos init blog-api --ts --prisma --redis
# 2. Add modules
cd blog-api
npx xacos add Posts
npx xacos add Comments
npx xacos add Users
# 3. Add features
npx xacos create:message-queue
npx xacos create:pub-sub
# 4. Setup deployment
npx xacos make:docker
npx xacos make:git-action
# 5. Install and run
npm install
npx prisma generate
npx prisma migrate dev
npm run dev🔧 Features
- ✅ Professional Structure - Industry-standard folder organization
- ✅ TypeScript Support - Full TypeScript support with type definitions
- ✅ Database Options - MongoDB (Mongoose) or Prisma ORM
- ✅ Real-time - WebSocket and Socket.io support
- ✅ Caching - Redis integration
- ✅ Job Queues - BullMQ for background jobs
- ✅ Event System - Pub/Sub for event-driven architecture
- ✅ Docker Ready - Docker and docker-compose setup
- ✅ CI/CD - GitHub Actions workflows
- ✅ Auto-wiring - Routes automatically registered
📚 Module Structure
When you run npx xacos add Users, you get:
Controller (user.controller.js):
getUsers()- GET /api/usersgetUserById()- GET /api/users/:idcreateUser()- POST /api/usersupdateUser()- PUT /api/users/:iddeleteUser()- DELETE /api/users/:id
Service (user.service.js):
- Business logic layer
- Calls model methods
Model (user.model.js):
- Database operations
- Adapts to MongoDB or Prisma automatically
Routes (user.routes.js):
- RESTful routes
- Auto-registered in
routes/index.js
🛠️ Tech Stack
- Express.js - Web framework
- Mongoose - MongoDB ODM (optional)
- Prisma - Next-generation ORM (optional)
- Redis - Caching and sessions (optional)
- BullMQ - Job queue (optional)
- Socket.io - Real-time communication (optional)
- WebSocket - Native WebSocket (optional)
📄 License
MIT
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📧 Support
For issues and feature requests, please use the GitHub issue tracker.
Built with ❤️ for the Node.js community
