A production-ready NestJS 11 module that instantly generates fully typed REST APIs and WebSockets for any MongoDB collection with zero boilerplate. Version 4.15.0 provides dual-token JWT authentication (access + refresh tokens), passwordless/OTP login, authorization with ability predicates, smart caching with auto-invalidation, WebSocket support, presence tracking, cascade delete, and typed lifecycle callbacks. Released under MIT license with weekly updates; ships TypeScript types. Alternative to @nestjsx/crud or building CRUD manually, with built-in authentication and real-time features.
npm install mongodb-dynamic-apiNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal setup: import DynamicApiModule, configure with entities, MongoDB URI, and JWT secret, then start NestJS app.
Destructure { accessToken, refreshToken } from login/register responses. Update any code expecting key 'token'.If relying on previous 1d expiry, set explicitly: jwt: { expiresIn: '1d' }. Refresh token must be stored and used with /auth/refresh-token.Ensure no duplicate route definitions for /auth/refresh-token or /auth/logout. Add guards as needed.
Migrate to dual-token auth: use refresh token for token renewal and logout invalidation.
Add a string field named 'refreshToken' to the user entity (or configure a different field name via refreshTokenField).
Run `npm install class-validator class-transformer` at project root.
Use named import: import { DynamicApiModule } from 'mongodb-dynamic-api'.Provide an array of entity/collection names: entities: ['users', 'posts'].
Add DynamicApiModule.forRoot({...}) to the imports of your root or feature module.