NestboltNestbolt

@nestbolt/factory

Installation

Install @nestbolt/factory and its required and optional peer dependencies.

Install the Package

Install @nestbolt/factory using your preferred package manager:

npm install @nestbolt/factory
yarn add @nestbolt/factory
pnpm add @nestbolt/factory

Peer Dependencies

The following packages are required peer dependencies. In a typical NestJS project, most of these are already installed:

PackageRequired VersionPurpose
@nestjs/common^10.0.0 || ^11.0.0NestJS core decorators and utilities
@nestjs/core^10.0.0 || ^11.0.0NestJS application core
@nestjs/typeorm^10.0.0 || ^11.0.0TypeORM integration for NestJS
typeorm^0.3.0ORM used for persisting entities
reflect-metadata^0.1.13 || ^0.2.0Metadata reflection for decorators

Install any missing peer dependencies:

npm install @nestjs/common @nestjs/core @nestjs/typeorm typeorm reflect-metadata

Included Dependencies

The following dependency is bundled with the package -- you do not need to install it separately:

PackageVersionPurpose
@faker-js/faker^9.0.0Generates realistic fake data for factory definitions

Optional Dependencies

Event Emitter (Seeder Lifecycle Events)

Required if you want to listen to seeder lifecycle events such as factory.seeder.started and factory.seed.all.completed.

npm install @nestjs/event-emitter

Supported 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 { FactoryModule } from "@nestbolt/factory";

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: "postgres",
      // ... your database config
      synchronize: true, // development only
    }),
    FactoryModule.forRoot({
      factories: [],
    }),
  ],
})
export class AppModule {}

If the application starts without errors and you see FactoryService initialized in the logs, the installation is complete. Continue to the Quick Start guide to define your first factory.