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

express-easy-curd

v2.1.2

Published

A lightweight helper library for building Express.js routes, controllers, advanced query with mongoose, and Redis-enhanced middleware with optional Redis support.

Readme

🚀 express-easy-curd

A lightweight helper library for building Express.js routes, controllers, and Redis-enhanced middleware. Simplify your CURD operations with flexible APIs, built-in helpers, and optional caching.

⚠️⚠️ Deprecated Package Notice

This package has been deprecated and is no longer maintained.

👉 Please use the new package instead:
xmcrud


You will find the latest updates, bug fixes, and new features there.



Watch the tutorial


  • ✅ Generic CURD controller for Mongoose models
  • ✅ Auto-generated Express routes
  • ✅ Optional Redis caching via ioredis
  • ✅ Query filtering and pagination helpers
  • ✅ TypeScript support with included types
  • ✅ Partial search and dynamic filtering

npm install express-easy-curd
# or
yarn add express-easy-curd

Peer dependencies: You must install compatible versions of express, mongoose, and optionally ioredis.

npm install express mongoose ioredis

1. Controller Example

import express from "express";
import mongoose from "mongoose";
import { generateCrudController } from "express-easy-curd";

const UserModel = mongoose.model("User", new mongoose.Schema({ name: String }));

const userController = generateCrudController(UserModel, "User");

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

app.get("/users", userController.getAll);
app.post("/users", userController.create);
app.put("/users", userController.updateMany);
app.patch("/users/update-many", userController.updateMany);
app.delete("/users/delete-many", userController.removeMany);

app.get("/users/:id", userController.getSingle);
app.put("/users/:id", userController.update);
app.patch("/users/:id", userController.update);
app.delete("/users/:id", userController.remove);

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

⚠️ Warning: Use proper validation for removeMany and updateMany to avoid unintended data loss.


2. Router Example

import express from "express";
import mongoose from "mongoose";
import { generateCrudRoutes } from "express-easy-curd";

const UserModel = mongoose.model("User", new mongoose.Schema({ name: String, age: Number }));

const curdRouter = generateCrudRoutes({
  mongooseModel: UserModel,
  name: "User",
  basePath: "/users",
  middlewares: {
    getAll: [...middlewares],
    create: [...middlewares],
    removeMany: [...middlewares],
    updateMany: [...middlewares],
    getSingle: [...middlewares],
    update: [...middlewares],
    remove: [...middlewares],
  },
});

const app = express();
app.use(express.json());
app.use("/api", curdRouter);

Generated Routes:

| Method | Path | Description | | ------ | ----------------------------------------- | ----------------- | | GET | /api/users | Get all users | | POST | /api/users | Create user | | PUT | /api/users?name=suronjit797 | Update many users | | PATCH | /api/users/update-many?name=suronjit797 | Update many users | | DELETE | /api/users/delete-many?name=suronjit797 | Delete many users | | GET | /api/users/:id | Get user by ID | | PUT | /api/users/:id | Update user by ID | | PATCH | /api/users/:id | Update user by ID | | DELETE | /api/users/:id | Delete user by ID |


3. With Redis Caching (Optional)

import Redis from "ioredis";
const redisClient = new Redis();

const userController = generateCrudController(UserModel, "User", redisClient, 600);

const curdRouter = generateCrudRoutes({
  mongooseModel: UserModel,
  name: "User",
  basePath: "/users",
  ioredis: redisClient,
  cachedTime: 600, // in seconds (default: 600 = 10 minutes)
});

  • filterHelper(req.query, partialKeys, model) – Builds MongoDB filters from query params
  • paginationHelper(req.query) – Handles pagination and sorting
  • sendResponse(res, data) – Standardizes API responses
  • ApiError – Custom error class
  • partialFilterMiddlewares(keys) – Enables partial search on string fields
const pagination = paginationHelper(req.query);
const filter = filterHelper(req.query, req.partialFilter || [], new UserModel());

const UserRouter = generateCrudRoutes({
  mongooseModel: UserModel,
  name: "User",
  middlewares: {
    getAll: [partialFilterMiddlewares(["name", "email"])],
  },
});

Use Mongoose-style operators in query strings:

| Operator | Query Param | | --------- | ----------- | | $gt | _gt | | $lt | _lt | | $gte | _gte | | $lte | _lte | | $ne | _ne | | $in | _in | | $nin | _nin | | $regex | _regex | | $exists | _exists |

Example:

GET /users?age_gt=10&name=suronjit797&search=item

Type definitions are included:

import { IMeta } from "express-easy-curd/dist/Types/types";

Pull requests and issues are welcome!


MIT © Suronjit Pal (@suronjit797)