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

@smartsoft001/crud-shell-nestjs

v2.211.0

Published

Utils to crud

Readme

📦 @smartsoft001/crud-shell-nestjs

npm downloads

🚀 Usage

npm i @smartsoft001/crud-shell-nestjs

🛠️ Modules

CrudShellNestjsModule

  • Provides the main integration module for CRUD features in a NestJS app.
  • Static method: forRoot(options) — Registers controllers, providers, and imports required modules with the given configuration.

CrudShellNestjsCoreModule

  • Provides a core integration module for CRUD features in a NestJS app.
  • Static method: forRoot(options) — Registers providers and imports required modules with the given configuration.

🛠️ Controllers & Methods

CrudController

🔒 Attachment access

The attachment routes are denied unless SharedConfig.attachmentPolicy returns exactly true. The policy is called with { operation, id, user } (operation is create, read or delete) before storage is read or changed. A valid JWT is not ownership: resolve owner, tenant and roles from data the server trusts, and never return an unconditional true for private files.

  • Linking a file to its uploader. For create, the controller generates the id first and passes it to the policy before reading the body. Record user against that id there and return true; later read and delete checks look the id up. A rejected upload can leave a record for an id with no file.
  • The stock Angular UI sends no token for files. The PDF and attachment displays open files with FileService.download (window.open), and the image, video and smartFileUrl displays load FileService.getUrl as plain URLs, so these are anonymous reads. With the stock UI, allow anonymous read for files meant to be viewable.
  • Status codes. A refusal is a DomainForbiddenError; it becomes 403 only when AppExceptionFilter from @smartsoft001/nestjs is registered (otherwise 500). A missing token on upload or delete is 401.
  • Limits. One file of at most attachmentMaxBytes (default 10 MiB) and at most attachmentMaxFields extra form fields (default 0). The file is buffered before storage; oversized, multi-file or extra-field requests answer 413 and nothing is stored. The upload answers only after the storage write finished.

Migration

The attachment routes used to have no guard. After upgrading: configure attachmentPolicy, register AppExceptionFilter, send a Bearer token on uploads and deletes, and raise attachmentMaxBytes or attachmentMaxFields if clients send larger files or extra form fields. Existing files have no ownership records; the policy decides how to treat them.

🛠️ Gateways & Methods

CrudGateway

🛡️ Query bounds and exports

GET / checks the query string before it reaches MongoDB and answers anything outside these bounds with 400 Bad Request:

  • Operators: =, !=, >, >=, <, <=, ~= and repeated keys (joined into one $in, at most 100 values). Raw Mongo operators ($where, $-keys other than $search, field:op=value) and /regex/ values are refused: they reach MongoDB as a $match stage, where an unbounded operator lets one request keep the database busy (denial of service).
  • Field names: letters, digits and underscores, dotted for nested fields, at most 128 characters; __proto__, prototype and constructor are refused.
  • ~= and $search are matched literally (the text is escaped before it becomes a regular expression) and are at most 256 characters. $search is always treated as text, so 48, 007 and true are searched as written. Other values are at most 1024 characters, the encoded query at most 4096.
  • limit is a positive integer, lowered to maxQueryLimit (default 100), which is also the page size when no limit is sent. offset is an integer from 0 to 10000; next and last links beyond it are left out.
  • CSV and XLSX exports use maxExportLimit (default 10000) instead. An export without limit that matches more rows is refused with 400 rather than truncated, and every export reports the match count in X-Total-Count.
  • CSV text cells starting with =, +, - or @ (also after spaces) or with a tab or line break get a leading apostrophe (OWASP CSV-injection guidance), so +48 600 000 000 is exported as '+48 600 000 000. Numbers are unchanged.
CrudShellNestjsModule.forRoot({
  // ...
  restApi: true,
  socket: false,
  maxQueryLimit: 500,
  maxExportLimit: 50000,
});

The bounds cap what one request asks for, not what it costs: index the fields you filter and sort on, scope data per customer, and set database timeouts and rate limits in the application.

Upgrading

  • A list request without limit now returns at most maxQueryLimit rows and a larger limit is lowered to it: page through the list or raise maxQueryLimit.
  • An offset above 10000 is refused.
  • Raw operators and /regex/ values are refused; use ~= for a "contains" match.
  • Field names containing __proto__, prototype or constructor are refused.
  • A CrudController subclass that calls super(service) gets the default limits; pass the injected SharedConfig as the second argument to use the configured ones.

Change subscriptions

A subscription is refused unless the socket handshake carries a valid JWT in auth.token (io(url, { auth: { token } })), the message names one entity with { id }, and SharedConfig.changePolicy returns exactly true. The policy receives { id, user, type }. It runs once on subscribe without type, and again before every event, with a fresh token check, with the change type (create, update or delete). A refusal on an event ends the subscription. Decide from server-side ownership or tenant data, never from the id alone.

  • Events carry no document fields. Clients receive { id, type } and refetch the entity through an authorized endpoint.
  • Deletes. Mongo emits a delete after the document is gone, so a policy that loads the document would deny it and the client would never learn about the delete. Branch on type === 'delete' and decide without loading the document.
  • Cost. The policy runs per event and per subscriber; keep it cheap or cache it.
  • Token expiry. The token from the handshake is rechecked on every event. After it expires the next event ends the subscription; the client must reconnect with a fresh auth.token.
  • Core module. CrudShellNestjsCoreModule always registers the gateway, so every subscription is refused until changePolicy is set.

Migration

Subscriptions used to be open to anyone, accepted an empty filter and carried the full change, including the inserted document or the update delta. After upgrading: configure changePolicy, connect with the JWT in auth.token (and reconnect after it expires), always subscribe with an id, and refetch the entity on each event instead of applying a payload.