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

crudify-kit

v1.0.1

Published

Reusable CRUD service & repository

Readme

Crudify-kit

A minimal and extendable CRUD service and repository layer for Node.js + MongoDB (Mongoose) projects. Easily integrate standard CRUD operations, validation, error handling, and custom business logic with clean architecture principles.


Installation

  npm i crudify-kit

Features

  • Reusable Repository Layer
  • Service Layer with Joi (or custom) Validation Support
  • Built-in Error Handling via AppError
  • Easily Extendable for Custom Logic
  • Works with CommonJS and ES Modules

Project Structure Explained

Repository Folder

This folder connects directly to the database (MongoDB via Mongoose). It contains methods like:

  • create(data) → Save a new document
  • get(id) → Fetch document by ID
  • update(id, data) → Update document
  • delete(id) → Delete document
  • getAll() → Fetch all documents
  • insertMany() → Insert bulk records
  • count(filter) → Count documents
  • exists(filter) → Check if any document exists

This layer deals only with raw DB queries.


Service Folder

This folder contains the business logic and connects the Repository to the outside world (like controllers).

  • Handles validation (via Joi or any function)
  • Uses AppError for consistent error responses
  • You can override methods for custom behavior

This is the logic layer, and what your API routes should call.


🛠️ Usage

Step 1: Create Your Mongoose Model (example)

// models/User.js
const mongoose = require('mongoose');
const userSchema = new mongoose.Schema({
  name: String,
  email: String,
});
module.exports = mongoose.model('User', userSchema);

Step 2: Create Repository

// repositories/UserRepository.js
const CrudRepository = require('crudify-kit').CrudRepository;
const User = require('../models/User');

class UserRepository extends CrudRepository {
  constructor() {
    super(User);
  }
}

module.exports = UserRepository;

Step 3: Add Validation (optional but recommended)

// validators/userValidator.js
const Joi = require('joi');

const userSchema = Joi.object({
  name: Joi.string().required(),
  email: Joi.string().email().required()
});

module.exports = {
  create: (data) => userSchema.validate(data).error,
  update: (data) => userSchema.validate(data).error
};

Step 4: Create Service

// services/UserService.js
const CrudService = require('crudify-kit').CrudService;
const UserRepository = require('../repositories/UserRepository');
const validators = require('../validators/userValidator');

class UserService extends CrudService {
  constructor() {
    super(new UserRepository(), { validators });
  }

  // You can override default methods if needed
  async get(id) {
    const user = await super.get(id);
    console.log('Fetched user:', user.name);
    return user;
  }
}

module.exports = UserService;

Importing in CommonJS or ESModules

// CommonJS
const { CrudService, CrudRepository, AppError } = require('crudify-kit');

// ES Modules
import { CrudService, CrudRepository, AppError } from 'crudify-kit';

Error Handling

Use AppError to throw custom errors from anywhere in your service or repository:

throw new AppError('User not found', 404);

In your global error handler middleware, you can catch and respond accordingly.


Advanced Usage

  • Inject custom validators, middlewares or logger
  • Create your own extended base classes if needed
  • Works with async/await and try/catch

Contributing

Pull requests are welcome. For major changes, please open an issue first.


License

MIT


Author

Created by jineksh chovatiya