npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@prodforcode/unipile-nestjs

v0.3.1

Published

NestJS integration module for Unipile API client

Readme

@prodforcode/unipile-nestjs

NestJS dynamic module for Unipile API integration with dependency injection support.

Installation

npm install @prodforcode/unipile-nestjs @prodforcode/unipile-core
# or
pnpm add @prodforcode/unipile-nestjs @prodforcode/unipile-core
# or
yarn add @prodforcode/unipile-nestjs @prodforcode/unipile-core

Quick Start

Basic Configuration

import { Module } from '@nestjs/common';
import { UnipileModule } from '@prodforcode/unipile-nestjs';

@Module({
  imports: [
    UnipileModule.forRoot({
      dsn: 'api6.unipile.com:13624',
      apiKey: 'your-api-key',
      isGlobal: true, // Make available everywhere
    }),
  ],
})
export class AppModule {}

Async Configuration

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { UnipileModule } from '@prodforcode/unipile-nestjs';

@Module({
  imports: [
    ConfigModule.forRoot(),
    UnipileModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        dsn: config.get('UNIPILE_DSN'),
        apiKey: config.get('UNIPILE_API_KEY'),
        enableRetry: true,
        timeout: 60000,
      }),
      isGlobal: true,
    }),
  ],
})
export class AppModule {}

Using a Configuration Class

import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { UnipileOptionsFactory, UnipileModuleOptions } from '@prodforcode/unipile-nestjs';

@Injectable()
class UnipileConfigService implements UnipileOptionsFactory {
  constructor(private readonly config: ConfigService) {}

  createUnipileOptions(): UnipileModuleOptions {
    return {
      dsn: this.config.get('UNIPILE_DSN'),
      apiKey: this.config.get('UNIPILE_API_KEY'),
    };
  }
}

@Module({
  imports: [
    ConfigModule.forRoot(),
    UnipileModule.forRootAsync({
      imports: [ConfigModule],
      useClass: UnipileConfigService,
      isGlobal: true,
    }),
  ],
})
export class AppModule {}

Injection Decorators

Use the provided decorators to inject Unipile services:

import { Injectable } from '@nestjs/common';
import {
  InjectUnipileClient,
  InjectAccountService,
  InjectEmailService,
  InjectMessagingService,
  InjectLinkedInService,
  InjectWebhookService,
  UnipileClient,
  AccountService,
  EmailService,
  MessagingService,
  LinkedInService,
  WebhookService,
} from '@prodforcode/unipile-nestjs';

@Injectable()
export class MyService {
  constructor(
    @InjectUnipileClient() private readonly client: UnipileClient,
    @InjectAccountService() private readonly accounts: AccountService,
    @InjectEmailService() private readonly email: EmailService,
    @InjectMessagingService() private readonly messaging: MessagingService,
    @InjectLinkedInService() private readonly linkedin: LinkedInService,
    @InjectWebhookService() private readonly webhooks: WebhookService,
  ) {}

  async sendWelcomeEmail(to: string): Promise<void> {
    await this.email.send({
      accountId: 'account-123',
      to: [{ email: to }],
      subject: 'Welcome!',
      body: 'Welcome to our service!',
    });
  }
}

Available Injection Tokens

| Decorator | Token | Type | |-----------|-------|------| | @InjectUnipileClient() | UNIPILE_CLIENT | UnipileClient | | @InjectAccountService() | UNIPILE_ACCOUNT_SERVICE | AccountService | | @InjectEmailService() | UNIPILE_EMAIL_SERVICE | EmailService | | @InjectMessagingService() | UNIPILE_MESSAGING_SERVICE | MessagingService | | @InjectLinkedInService() | UNIPILE_LINKEDIN_SERVICE | LinkedInService | | @InjectWebhookService() | UNIPILE_WEBHOOK_SERVICE | WebhookService |

Example Controller

import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import {
  InjectEmailService,
  InjectAccountService,
  EmailService,
  AccountService,
  SendEmailRequest,
  Account,
  PaginatedResponse,
} from '@prodforcode/unipile-nestjs';

@Controller('unipile')
export class UnipileController {
  constructor(
    @InjectEmailService() private readonly email: EmailService,
    @InjectAccountService() private readonly accounts: AccountService,
  ) {}

  @Get('accounts')
  async listAccounts(): Promise<PaginatedResponse<Account>> {
    return this.accounts.list({ limit: 50 });
  }

  @Get('accounts/:id')
  async getAccount(@Param('id') id: string): Promise<Account> {
    return this.accounts.get(id);
  }

  @Post('emails')
  async sendEmail(@Body() request: SendEmailRequest): Promise<void> {
    await this.email.send(request);
  }
}

Webhook Handler Example

import { Controller, Post, Body, Headers, HttpException, HttpStatus } from '@nestjs/common';
import {
  InjectWebhookService,
  WebhookService,
  MessageReceivedPayload,
  WebhookEvent,
} from '@prodforcode/unipile-nestjs';

@Controller('webhooks')
export class WebhookController {
  constructor(
    @InjectWebhookService() private readonly webhooks: WebhookService,
  ) {}

  @Post('unipile')
  async handleWebhook(
    @Body() body: string,
    @Headers('x-unipile-signature') signature: string,
  ): Promise<void> {
    // Verify signature
    const secret = process.env.WEBHOOK_SECRET;
    if (!this.webhooks.verifySignature(body, signature, secret)) {
      throw new HttpException('Invalid signature', HttpStatus.UNAUTHORIZED);
    }

    // Parse and handle payload
    const payload = this.webhooks.parsePayload<MessageReceivedPayload>(body);

    if (payload.event === WebhookEvent.MESSAGE_RECEIVED) {
      console.log(`New message from ${payload.sender.name}: ${payload.text}`);
      // Handle message...
    }
  }
}

Module Options

interface UnipileModuleOptions {
  /** API domain:port (e.g., "api6.unipile.com:13624") */
  dsn: string;

  /** API access token */
  apiKey: string;

  /** Use HTTP instead of HTTPS (default: false) */
  useHttp?: boolean;

  /** Request timeout in milliseconds (default: 30000) */
  timeout?: number;

  /** Enable automatic retry with exponential backoff (default: true) */
  enableRetry?: boolean;

  /** Base delay for exponential backoff in ms (default: 300000) */
  retryBaseDelay?: number;

  /** Maximum delay for exponential backoff in ms (default: 7200000) */
  retryMaxDelay?: number;

  /** Maximum number of retry attempts (default: 5) */
  maxRetries?: number;

  /** Register as global module (default: false) */
  isGlobal?: boolean;
}

Re-exports

This package re-exports everything from @prodforcode/unipile-core for convenience:

import {
  // Types
  Account,
  Email,
  Chat,
  Message,
  LinkedInCompany,
  LinkedInPerson,
  Webhook,

  // Enums
  AccountStatus,
  AccountProvider,
  WebhookSource,
  WebhookEvent,
  CheckpointType,
  ErrorCategory,

  // Errors
  UnipileError,
  TimeoutError,
  ConnectionError,
  RateLimitError,
  AuthError,
  ValidationError,
  NotFoundError,
} from '@prodforcode/unipile-nestjs';

License

MIT