zola-nestjs-shared
v0.1.9
Published
zola-nestjs-shared is a shared package for NestJS applications
Readme
zola-nestjs-shared
A shared package for NestJS applications providing common utilities, modules, and services.
Installation
Standard Installation
npm install zola-nestjs-sharedKnown Issue: nestjs-minio-client Postinstall Script
If you encounter an error during installation related to husky not being found:
npm error 'husky' is not recognized as an internal or external commandThis is caused by the nestjs-minio-client dependency having a problematic postinstall script. To work around this, install with the --ignore-scripts flag:
npm install zola-nestjs-shared --ignore-scriptsNote: This will skip all postinstall scripts, including the problematic one from nestjs-minio-client. The package will still function correctly as the postinstall script is only for setting up git hooks in the nestjs-minio-client repository itself, not required for runtime functionality.
Alternative: Install Husky in Your Project
If you prefer not to use --ignore-scripts, you can install husky as a dev dependency in your consuming project:
npm install --save-dev husky
npm install zola-nestjs-sharedHowever, this is not recommended as it adds an unnecessary dependency to your project.
Peer Dependencies
This package requires the following peer dependencies to be installed in your consuming project:
@nestjs/common:^10.0.0 || ^11.0.0@nestjs/core:^10.0.0 || ^11.0.0@nestjs/config:^3.0.0 || ^4.0.0@nestjs/jwt:^10.0.0 || ^11.0.0@nestjs/passport:^10.0.0 || ^11.0.0@nestjs/platform-express:^10.0.0 || ^11.0.0reflect-metadata:^0.1.0 || ^0.2.0rxjs:^7.0.0 || ^8.0.0
Optional peer dependencies (only needed if using specific features):
@nestjs/schedule:^4.0.0 || ^5.0.0 || ^6.0.0(for scheduling features)@nestjs/swagger:^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0(for Swagger/OpenAPI)@nestjs/throttler:^5.0.0 || ^6.0.0(for rate limiting)@nestjs/microservices:^10.0.0 || ^11.0.0(for microservices)amqplib:^0.10.0(required only if using audit features with RabbitMQ)@nestjs/typeorm:^10.0.0 || ^11.0.0(for TypeORM features)typeorm:^0.3.0(for TypeORM features)
Using Audit Features
Important: You can use this package without amqplib even if you import AuditModule. The module will automatically detect if dependencies are available and only enable audit features if both @nestjs/microservices and amqplib are installed.
The amqplib dependency is only required when you want to actually use audit logging features:
Importing
AuditModule- This is now safe even withoutamqplib:import { AuditModule } from 'zola-nestjs-shared'; @Module({ imports: [AuditModule], // ✅ Safe - will work without amqplib (audit features will be disabled) })Using audit decorators or interceptors - These will only work if dependencies are installed:
import { AuditLoggerInterceptor } from 'zola-nestjs-shared'; import { AUDIT_RMQ_EVENT } from 'zola-nestjs-shared';
If you plan to use the audit logging features (which use RabbitMQ), you must install both @nestjs/microservices and amqplib:
npm install @nestjs/microservices amqplibNote: The audit module uses RabbitMQ (Transport.RMQ) for event logging. The module will automatically check if amqplib and @nestjs/microservices are available:
- ✅ If both are installed: Audit features will be enabled and work normally
- ✅ If either is missing: The module will load successfully but audit features will be disabled (you'll see a warning in development mode)
You can safely import AuditModule without amqplib - the package will work correctly for all other features, and audit features will simply be disabled.
Usage
import { Module } from '@nestjs/common';
import { AuthorizationModule } from 'zola-nestjs-shared';
@Module({
imports: [AuthorizationModule],
})
export class AppModule {}License
ISC
