@nest-extended/core

The foundation every other package builds on — the generic CRUD controller, the dynamic configuration module, the null-response interceptor and the shared types.

$npm install @nest-extended/core nestjs-cls

Key exports

ExportTypePurpose
NestController<T>classBase controller — find / get / create / patch / delete
NestExtendedModulemoduleDynamic module configured via .forRoot(config)
NullResponseInterceptorinterceptorThrows 404 when a GET resolves to null
getCurrentUser<T>()functionRead the authenticated user from CLS
NEST_EXTENDED_CONFIGtokenDI token for the resolved config
NestExtendedConfigtypeRoot config (soft delete, query parser)
ServiceOptions<T>interfaceService contract used by NestController
PaginatedResponse<D>type{ total, $limit, $skip, data }

Generic controller

NestController wires the CRUD routes to any service implementing ServiceOptions:

cats.controller.ts
import { Controller } from '@nestjs/common';
import { NestController } from '@nest-extended/core';
import { CatsService } from './cats.service';
 
@Controller('cats')
export class CatsController extends NestController<Cat> {
  constructor(service: CatsService) {
    super(service);
  }
}

Module configuration

app.module.ts
NestExtendedModule.forRoot({
  queryParser: { depth: 20, arrayLimit: 100 },
});

Next steps