JSPM

  • Created
  • Published
  • Downloads 56
  • Score
    100M100P100Q63030F
  • License MIT

Universal CRUD Generator - Express.js plugin and CLI tool for generating Node.js CRUD APIs with database models, controllers, and admin interface

Package Exports

  • ucg
  • ucg/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ucg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

UCG - Universa```bash

Global installation (for CLI)

const express = require('express');
const ucg = require('ucg');

const app = express();
app.use(express.json());

// Initialize UCG plugin
const ucgPlugin = ucg({ll -g ucg

# Local installation (for plugin use)
npm install ucg

CLI Usage

# Initialize UCG in your project
ucg init

# Start the admin interface
ucg start

# Generate CRUD operations
ucg generate:crud --model User
```Express.js plugin and CLI tool for generating Node.js CRUD APIs with database models, controllers, and admin interface**

[![npm version](https://badge.fury.io/js/ucg.svg)](https://badge.fury.io/js/ucg) - Node CRUD Generator

**Express.js plugin and CLI tool for generating Node.js CRUD APIs with database models, controllers, and admin interface**

[![npm version](https://badge.fury.io/js/ucg.svg)](https://badge.fury.io/js/ucg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js Version](https://img.shields.io/badge/node-%3E%3D16.0.0-brightgreen.svg)](https://nodejs.org/)

## 🚀 Quick Start

### Installation

```bash
# Global installation (for CLI)
npm install -g ucg

# Local installation (for plugin use)
npm install ucg

Quick Setup (Fastest Way)

# One-command setup - creates a new project with UCG
npx ucg quick-setup --name my-api

# With custom database
npx ucg quick-setup --name my-api --db postgres

# Navigate to your project and start
cd my-api
npm start

CLI Usage

# Initialize UCG in your project
ucg init

# Start the admin interface
ucg start

# Generate CRUD operations
ucg generate:crud --model User

Plugin Usage

const express = require('express');
const ucg = require('ucg');

const app = express();
app.use(express.json());

// Initialize UCG plugin
const ucgPlugin = ucg({
  mountPath: '/admin',
  autoRegisterRoutes: true
});

app.use('/admin', ucgPlugin.initialize(app));

app.listen(3000, () => {
  console.log('🚀 Server running on http://localhost:3000');
  console.log('📊 UCG Admin at http://localhost:3000/admin');
});

✨ Features

  • 🔥 Auto Database Config: Automatically creates database configuration during CRUD generation
  • 🔄 Auto Route Mounting: Generated routes are automatically integrated into your app
  • 🔐 Session Management: Robust session handling with proper async initialization
  • 🖥️ CLI & Web Interface: Both command-line and web-based management
  • 🗄️ Multiple ORMs: Support for Sequelize, TypeORM, and Knex
  • 📚 Swagger Documentation: Auto-generated API documentation
  • ✅ Validation: Input validation with Joi
  • 🔗 Relational Data: Complete support for associations and related data

📖 Documentation

Database Configuration

Create a .env file in your project root:

DB_HOST=localhost
DB_PORT=5432
DB_NAME=your_database
DB_USER=your_username
DB_PASS=your_password

Available Commands

ncg init                     # Initialize NCG in current project
ncg start                    # Start admin interface
ncg generate:model --table users    # Generate model from table
ncg generate:crud --model User      # Generate CRUD operations
ncg help                     # Show all commands

Plugin Options

const ncgPlugin = ncg({
  mountPath: '/admin',           // Mount path for admin interface
  autoRegisterRoutes: true,      // Auto-mount generated routes
  configDir: '.ncg',            // Configuration directory
  swaggerConfig: {
    title: 'My API',
    version: '1.0.0',
    description: 'API Documentation'
  }
});

🏗️ Generated Structure

UCG generates a complete CRUD API structure:

src/
├── config/
│   └── database.js          # Auto-generated database configuration
├── models/
│   ├── index.js            # Auto-generated models index
│   └── User.js             # Generated model
├── controllers/
│   └── userController.js   # Generated controller
├── services/
│   └── userService.js      # Generated service layer
├── routes/
│   └── userRoutes.js       # Generated routes
├── validators/
│   └── userValidator.js    # Generated validation
└── docs/
    └── swagger/
        └── user.swagger.js  # Generated API docs

🔧 Supported Databases

  • PostgreSQL (Recommended)
  • MySQL/MariaDB
  • SQLite

🔧 Supported ORMs

  • Sequelize (Default)
  • TypeORM
  • Knex.js

📝 API Features

Generated APIs include:

  • GET /api/users - List all users with pagination, filtering, and search
  • GET /api/users/:id - Get user by ID with relational data
  • POST /api/users - Create new user with validation
  • PUT /api/users/:id - Update user with validation
  • DELETE /api/users/:id - Delete user

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Support

  • Issues: GitHub Issues
  • Documentation: Available in the admin interface
  • Examples: Included in the package

Made with ❤️ by the UCG Contributors