CRUDMan for NestJS

A minimal, adapter-driven CRUD layer for NestJS. From zero to production in minutes—no boilerplate, no fuss. Decorate, ship, scale.

// companies.controller.ts
import { Controller } from '@nestjs/common'
import { UseCrud, CrudControllerBase } from 'crudman-nestjs'
import { Company } from './company.entity'

@UseCrud({ sections: { companies: { model: Company } } })
@Controller('api/companies')
export class CompaniesController extends CrudControllerBase('companies') {}
$ Generated APIs (no boilerplate):
$ GET    /api/companies
$ GET    /api/companies/:id
$ POST   /api/companies
$ PATCH  /api/companies/:id
$ DELETE /api/companies/:id
GitHub stars NPM downloads CI Chat License

Why crudman?

Plug-and-play

Drop-in module, instant CRUD routes, and elegant overrides when you need full control.

Adapter-first

TypeORM today, Sequelize-ready tomorrow—swap ORM or validators without upheaval.

Swagger-native

Entity-driven schemas with polished response envelopes for list, details, create, update, delete.

Features

Models shorthand
Generate CRUD for multiple models in one controller with @UseCrud({ models: [...] }). See README for overrides, include/exclude, and model-first usage.
Auto CRUD endpoints
Spin up list, details, create, update, delete—in a single decorator or base class.
PATCH-first updates
Modern partial updates by default (configurable to PUT).
Relations by default
Include all relations automatically; fine-tune with include/exclude patterns.
Attributes selection
All columns by default, plus include/exclude to shape payloads.
Powerful querying
Clean filtering, sorting, pagination, and keyword search with safe whitelists.
Validation built-in
Fastest-validator out of the box; swap to Joi/Zod via adapters.
Caching
Per-endpoint NodeCache with smart invalidation after writes.
Hooks everywhere
Before/after action, query, and validation—extend without forking.
Swagger enhancer
Auto envelopes for list/details/create/update/delete; entity schemas derived from metadata.
Save (upsert)
Single endpoint to create or update based on presence of an id.
Programmatic calls
Call other sections’ actions safely within hooks or services.
CSV/Excel export
One header switch away—deliver CSV or Excel without code changes.
Bulk import
Effortless data onramp with conflict policies, batching, and dry runs.
Bulk delete
Clear data at scale with safety valves and transparent reporting.

Install

$ npm i crudman-nestjs

One-minute setup

// users.controller.ts
import { Controller } from '@nestjs/common'
import { UseCrud, CrudControllerBase } from 'crudman-nestjs'
import { User } from './user.entity'

@UseCrud({ sections: { users: { model: User } } })
@Controller('api/users')
export class UsersController extends CrudControllerBase('users') {}

README

Supported upload types (presets)

Use these presets in uploadable or typeHint. Override MIME/ext/size per field via validators. Avatar presets also enforce image dimensions.

TypeAllowed MIME typesExtensionsMax size (MB)Image constraintsNotes
imagejpeg, png, gif, webp, avif.jpg,.jpeg,.png,.gif,.webp,.avif5—group
image-jpgimage/jpeg.jpg,.jpeg5—
image-pngimage/png.png5—
image-gifimage/gif.gif5—
image-webpimage/webp.webp5—
image-avifimage/avif.avif5—
image-avatarjpeg, png, gif, webp, avif.jpg,.jpeg,.png,.gif,.webp,.avif2min 128x128, max 4096x4096, aspect ~1:1avatars
videovideo/mp4, video/webm, video/ogg.mp4,.webm,.ogg100—
video-shortvideo/mp4, video/webm.mp4,.webm25—short clips
audioaudio/mpeg, audio/mp4, audio/aac, audio/ogg, audio/wav.mp3,.m4a,.aac,.ogg,.wav20—
pdf—.pdf10—
doc—.pdf,.doc,.docx,.odt10—
spreadsheet—.xls,.xlsx,.csv10—group
spreadsheet-csvtext/csv.csv5—
spreadsheet-xlsapplication/vnd.ms-excel.xls10—
spreadsheet-xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet.xlsx10—
csvtext/csv.csv5—
xmlapplication/xml, text/xml.xml2—
htmltext/html.html,.htm2—
jsonapplication/json.json2—
texttext/plain, text/markdown.txt,.md2—
archive—.zip,.tar,.gz,.rar,.7z200—
binaryapplication/octet-streamany50—raw blobs

Default storage: filename_in_field (relative key saved in the entity field). Responses include meta.baseUrls on list/details; clients can set x-file-url=full|key_only to indicate URL preference.

About

logo
Jinu Joseph Daniel
Author