Skip to content

zoherr/xacos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ 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 xacos

Use 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 --prisma

Options:

  • --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 --docker

add <name> - Add a new module

Creates a complete module with controller, service, model, and routes.

npx xacos add User
npx xacos add notification
npx xacos add product

This command generates:

  • src/controllers/{name}.controller.js
  • src/services/{name}.service.js
  • src/models/{name}.model.js
  • src/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:redis

Creates 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:prisma

Creates:

  • prisma/schema.prisma
  • src/config/db.js (Prisma client)

create:ws - Create native WebSocket setup

Sets up native WebSocket server.

npx xacos create:ws

Creates src/sockets/index.js with WebSocket server configuration.

create:socket.io - Create Socket.io setup

Sets up Socket.io server.

npx xacos create:socket.io

Creates 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-queue

Creates 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-sub

Creates:

  • src/utils/pubsub.js - Event emitter wrapper
  • src/subscribers/index.js - Example subscribers

make:docker - Create Docker files

Creates Dockerfile and docker-compose.yml.

npx xacos make:docker

Creates:

  • docker/Dockerfile
  • docker/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-action

Creates .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

  1. Create a new project:

    npx xacos init my-api --js --mongodb
  2. Add a module:

    cd my-api
    npx xacos add User
  3. Install dependencies:

    npm install
  4. Start 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/users
  • getUserById() - GET /api/users/:id
  • createUser() - POST /api/users
  • updateUser() - PUT /api/users/:id
  • deleteUser() - 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

About

Backend scaffolding CLI

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors