npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

crud-api-fatezila

v1.0.0

Published

Generate a complete CRUD API with authentication, user management, and MySQL database setup

Downloads

2

Readme

🚀 CRUD API Generator

A powerful NPX package that generates a complete CRUD API with authentication, user management, and MySQL database setup.

✨ Features

  • Complete CRUD Operations - Full Create, Read, Update, Delete functionality
  • JWT Authentication - Secure user authentication and authorization
  • User Management - Registration, login, profile management
  • MySQL Database - Robust database with connection pooling
  • Rate Limiting - Built-in protection against abuse
  • Input Validation - Comprehensive data validation and sanitization
  • Error Handling - Professional error handling and logging
  • API Documentation - Auto-generated API documentation
  • Sample Data - Pre-configured with sample data for testing

🎯 Quick Start

Install and Generate Project

# Generate a new CRUD API project
npx crud-api-generator my-awesome-api

# Navigate to your project
cd my-awesome-api

# Setup database
npm run setup

# Start the server
npm start

Default Admin Credentials

⚠️ Important: Change the default password after first login!

📊 Generated Project Structure

my-awesome-api/
├── lib/                          # Core application files
│   ├── server.js                 # Express server setup
│   ├── database/
│   │   ├── connection.js         # Database connection
│   │   └── schema.sql            # Database schema
│   ├── routes/                   # API routes
│   │   ├── auth.js              # Authentication routes
│   │   ├── paket-pengadaan.js   # Main CRUD routes
│   │   └── users.js             # User management routes
│   ├── functions/                # CRUD functions
│   │   ├── create.js            # Create operations
│   │   ├── read.js              # Read operations
│   │   ├── update.js            # Update operations
│   │   └── delete.js            # Delete operations
│   ├── middleware/               # Middleware
│   │   ├── errorHandler.js      # Error handling
│   │   └── notFound.js          # 404 handler
│   └── validation/               # Validation schemas
│       └── paketValidation.js   # Data validation
├── templates/                    # Template files
│   ├── env.example              # Environment template
│   └── config.example.js        # Configuration template
├── docs/                         # Documentation
│   ├── README.md                # This file
│   └── API.md                   # API documentation
├── scripts/                      # Setup scripts
│   ├── setup.js                 # Database setup
│   └── init-project.js          # Project initialization
├── package.json                  # Dependencies and scripts
├── .env                         # Environment configuration
└── test-api.js                  # API testing script

🔌 API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/refresh-token - Refresh JWT token
  • POST /api/auth/verify-token - Verify JWT token

User Management

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update user profile
  • PUT /api/users/change-password - Change password
  • DELETE /api/users/account - Delete account

Main CRUD Operations

  • GET /api/paket-pengadaan - List all records (with pagination)
  • POST /api/paket-pengadaan - Create new record
  • GET /api/paket-pengadaan/:id - Get record by ID
  • PUT /api/paket-pengadaan/:id - Update record by ID
  • DELETE /api/paket-pengadaan/:id - Delete record by ID
  • GET /api/paket-pengadaan/search - Advanced search with filters
  • POST /api/paket-pengadaan/search - Search by kode paket
  • POST /api/paket-pengadaan/bulk-delete - Bulk delete records
  • GET /api/paket-pengadaan/utils - Test database connection
  • POST /api/paket-pengadaan/utils - Check duplicate files

System

  • GET /health - Health check
  • GET /api - API documentation

🗄️ Database Schema

Users Table

  • User authentication and profile management
  • JWT token support
  • Password hashing with bcrypt

Paket Pengadaan Table

  • Main data table with comprehensive fields
  • Full-text search support
  • Optimized indexes for performance

Subscription Plans

  • Free, Premium 3 Month, Premium 12 Month
  • Configurable daily view limits
  • Favorites management

Additional Tables

  • user_subscriptions - User subscription management
  • daily_views - View tracking and limits
  • user_favorites - User favorites system
  • payments - Payment history tracking

⚙️ Configuration

Environment Variables

Create a .env file in your project root:

# Server Configuration
NODE_ENV=development
PORT=3000

# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=crud_api_db

# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=24h

# API Configuration
API_BASE_URL=http://localhost:3000/api
CORS_ORIGIN=http://localhost:3000

# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100

# Security
BCRYPT_ROUNDS=12

🚀 Available Scripts

# Start the server
npm start

# Start in development mode with auto-reload
npm run dev

# Setup database (run once after installation)
npm run setup

# Initialize project (create additional files)
npm run init

# Test API endpoints
npm test

# Run all tests including setup
npm run test:setup

📝 Usage Examples

Create a New Record

curl -X POST http://localhost:3000/api/paket-pengadaan \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "tender_001.pdf",
    "md5_hash": "a1b2c3d4e5f6789012345678901234ab",
    "kode_paket": "PKT-2025-001",
    "nama_paket": "Pembangunan Jalan Raya",
    "tanggal_pembuatan": "2025-01-15",
    "kl_pd_instansi": "Pemerintah Kota Jakarta",
    "satuan_kerja": "Dinas Pekerjaan Umum",
    "jenis_pengadaan": "Konstruksi",
    "metode_pengadaan": "Tender Terbuka",
    "nilai_pagu_paket": 5000000000,
    "nilai_hps_paket": 4500000000,
    "lokasi_pekerjaan": "Jakarta Pusat",
    "syarat_kualifikasi": "Memiliki SIUJK minimal Klasifikasi M4",
    "peserta_non_tender": "Tidak"
  }'

Search with Filters

curl "http://localhost:3000/api/paket-pengadaan/search?instansi=Jakarta&nilai_min=1000000&limit=10"

User Registration

curl -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "email": "[email protected]",
    "password": "securepassword123",
    "full_name": "John Doe"
  }'

🔒 Security Features

  • JWT Authentication - Secure token-based authentication
  • Password Hashing - bcrypt with configurable rounds
  • Rate Limiting - Protection against abuse
  • Input Validation - Comprehensive data validation
  • SQL Injection Protection - Prepared statements
  • CORS Configuration - Configurable cross-origin requests
  • Helmet.js - Security headers

📊 Performance Features

  • Connection Pooling - Efficient database connections
  • Database Indexes - Optimized query performance
  • Pagination - Large dataset handling
  • Full-text Search - Fast content searching
  • Caching Headers - Browser caching optimization

🧪 Testing

Automated Testing

# Run API tests
npm test

# Test with sample data
npm run test:setup

Manual Testing

  1. Start the server: npm start
  2. Visit: http://localhost:3000/api for API documentation
  3. Visit: http://localhost:3000/health for health check
  4. Use the provided test script: node test-api.js

📚 API Documentation

Complete API documentation is available at:

  • Generated Project: http://localhost:3000/api
  • Documentation File: docs/API.md

🛠️ Customization

Adding New Routes

  1. Create route file in lib/routes/
  2. Import in lib/server.js
  3. Add to API documentation

Modifying Database Schema

  1. Edit lib/database/schema.sql
  2. Run npm run setup to update database
  3. Update validation schemas if needed

Adding New Validation

  1. Edit lib/validation/paketValidation.js
  2. Add validation rules
  3. Test with sample data

🐛 Troubleshooting

Common Issues

Database Connection Failed

  • Check MySQL server is running
  • Verify database credentials in .env
  • Ensure database exists

Port Already in Use

  • Change PORT in .env file
  • Or kill process using the port

JWT Token Issues

  • Check JWT_SECRET in .env
  • Verify token expiration settings

Permission Denied

  • Ensure proper file permissions
  • Run with appropriate user privileges

Getting Help

  1. Check the generated docs/API.md file
  2. Review the console output for error messages
  3. Verify your .env configuration
  4. Test database connection manually

📄 License

MIT License - Feel free to use and modify as needed.

🤝 Contributing

This is a generated project template. You can:

  • Modify the generated code for your needs
  • Add new features and routes
  • Customize the database schema
  • Enhance the validation rules

🎉 What's Next?

After generating your CRUD API:

  1. Customize the Schema - Modify lib/database/schema.sql for your data
  2. Add Business Logic - Extend the CRUD functions for your needs
  3. Implement Frontend - Build a web or mobile app to consume the API
  4. Deploy - Deploy to your preferred hosting platform
  5. Monitor - Add logging and monitoring for production use

Generated by CRUD API Generator v1.0.0
Happy coding! 🚀