@nestbolt/sluggable
Installation
Install @nestbolt/sluggable and its required and optional peer dependencies.
Install the Package
Install @nestbolt/sluggable using your preferred package manager:
npm install @nestbolt/sluggableyarn add @nestbolt/sluggablepnpm add @nestbolt/sluggablePeer Dependencies
The following packages are required peer dependencies. In a typical NestJS project, most of these are already installed:
| Package | Required Version | Purpose |
|---|---|---|
@nestjs/common | ^10.0.0 || ^11.0.0 | NestJS core decorators and utilities |
@nestjs/core | ^10.0.0 || ^11.0.0 | NestJS application core |
typeorm | ^0.3.0 | ORM used for entity subscribers and queries |
reflect-metadata | ^0.1.13 || ^0.2.0 | Metadata reflection for decorators |
Install any missing peer dependencies:
npm install @nestjs/common @nestjs/core typeorm reflect-metadataOptional Dependencies
Event Emitter (Slug Lifecycle Events)
Required if you want to listen to slug generation events such as sluggable.slug-generated and sluggable.slug-regenerated.
npm install @nestjs/event-emitterSupported versions: ^2.0.0 || ^3.0.0
You also need to register the EventEmitterModule in your application:
import { EventEmitterModule } from "@nestjs/event-emitter";
@Module({
imports: [
EventEmitterModule.forRoot(),
// ... other imports
],
})
export class AppModule {}If @nestjs/event-emitter is not installed, the package works normally but no events are emitted. The event emitter is injected as an optional dependency.
Verifying the Installation
After installing, verify everything is wired correctly by importing the module in your root AppModule:
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { SluggableModule } from "@nestbolt/sluggable";
@Module({
imports: [
TypeOrmModule.forRoot({
type: "postgres",
// ... your database config
synchronize: true, // development only
}),
SluggableModule.forRoot(),
],
})
export class AppModule {}If the application starts without errors and you see SluggableService initialized in the logs, the installation is complete. Continue to the Quick Start guide to create your first sluggable entity.