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

full-crud

v1.0.1

Published

Zero-boilerplate CRUD factory for Express and Mongoose. Autowire your entire API in one line.

Readme

full-crud

Automated CRUD API Generator for Express and Mongoose

full-crud is a high-level utility that eliminates repetitive CRUD controller boilerplate in Express.js applications using Mongoose. Generate complete, production-ready REST APIs with pagination, filtering, and field selection in a single line of code.


Table of Contents


Installation

npm install full-crud

Peer Dependencies:

  • express any version
  • mongoose any version

Quick Start

1. Automatic Model Registration (Autowire)

Register all Mongoose models in a directory as REST endpoints automatically:

const express = require('express');
const mongoose = require('mongoose');
const { autowire } = require('full-crud');

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

// Connect to your MongoDB database
mongoose.connect('mongodb://localhost:27017/myapp');

// Automatically creates CRUD endpoints for all models in ./models
// Example: User model -> GET /api/users, POST /api/users, etc.
autowire(app, './models');

app.listen(3000, () => console.log('Server running on port 3000'));

2. Manual Model Mounting

Mount specific models to custom paths with additional configuration:

const { mountCrud } = require('full-crud');
const User = require('./models/User');

// Register User model at /api/users
mountCrud(app, '/api/users', User, {
  pagination: { defaultLimit: 25, maxLimit: 100 }
});

3. Standalone Controller Builder

Create reusable controller instances with a fluent API:

const { makeCrud } = require('full-crud');
const User = require('./models/User');

// Create a fully configured controller
const userController = makeCrud(User)
  .pagination({ defaultLimit: 50 })
  .beforeCreate(async (data) => {
    // Hash password before saving
    if (data.password) {
      data.password = await bcrypt.hash(data.password, 10);
    }
    return data;
  });

// Use in your Express routes
app.get('/api/users', userController.getAll);
app.post('/api/users', userController.create);

Features

Automated CRUD Operations

  • GET /resource - Retrieve all resources with pagination & filtering
  • GET /resource/:id - Retrieve single resource by ID
  • POST /resource - Create new resource
  • PUT /resource/:id - Update existing resource
  • DELETE /resource/:id - Delete resource

Built-in Query Parameters

All list endpoints (GET /resource) support the following query parameters:

| Parameter | Description | Example | |-----------|-------------|---------| | page | Page number for pagination | ?page=2 | | limit | Items per page | ?limit=50 | | sort | Sort by field (prefix with - for descending) | ?sort=-createdAt | | fields | Select specific fields | ?fields=name,email,createdAt | | [field] | Filter by any model field | ?status=active&category=electronics |

Automatic Response Format

All responses follow a consistent format:

// Success response (GET ALL)
{
  "success": true,
  "count": 20,
  "pagination": {
    "page": 1,
    "limit": 20,
    "totalPages": 5,
    "totalItems": 100
  },
  "data": [ /* array of resources */ ]
}

// Success response (GET BY ID / CREATE)
{
  "success": true,
  "data": { /* resource data */ }
}

API Reference

autowire(app, modelsPath, options)

Automatically registers CRUD routes for all Mongoose models in a directory.

Options:

  • prefix (String): URL prefix (default: /api)
  • logging (Boolean): Enable route table logging in terminal (default: true)

mountCrud(app, path, Model, options)

Mounts CRUD operations for a single model at a specified path.

makeCrud(Model, options)

Creates a CRUD controller instance with a fluent API for method chaining.


Configuration Options

Fluent API Methods

const controller = makeCrud(User)
  .pagination({ defaultLimit: 30, maxLimit: 100 }) // Configure pagination
  .only(['getAll', 'getById', 'create'])           // Enable only specific operations
  .middleware('create', [auth, validateUser])      // Add middleware per operation
  .beforeCreate(async (data, req) => data)         // Add pre-save hook
  .afterCreate(async (doc, req) => {})             // Add post-save hook
  .beforeUpdate(async (data, req) => data);        // Add pre-update hook

Error Handling

full-crud provides comprehensive error handling for Mongoose validation, cast errors (invalid IDs), and duplicate entries:

// Error response
{
  "success": false,
  "error": "Validation Error",
  "details": "User validation failed: email: Path `email` is required."
}

License

MIT © MARHOUM Abdelaziz