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

@ad0nis/openvpn-manager-nestjs

v0.1.3

Published

Nestjs module for integrating with openvpn-manager-ts

Readme

OpenVPN Manager NestJS

A NestJS integration module for openvpn-manager.

This package provides dependency injection and module configuration for working with OpenVPN through openvpn-manager-ts in NestJS applications.

Features

  • Seamless integration with openvpn-manager
  • Type-safe event handling
  • Flexible configuration (supports async factories)
  • Optional custom event emitter and logger injection

Quick Start

To get started, register the module in your NestJS application:

[!NOTE] For detailed setup instructions, refer to the original repository. The only difference here is how the logger is configured — see examples below.

install

npm

npm install @ad0nis/openvpn-manager-nestjs

yarn

yarn add @ad0nis/openvpn-manager-nestjs
@Module({
  imports: [
    OpenvpnModuleImpl.forRootAsync({
      useFactory: () => {
        return {
          connections: [
            {
              id: "srv1",         // Server identifier (any string)
              host: "127.0.0.1",  // OpenVPN Manager host
              port: 7505,         // OpenVPN Manager port
              timeout: 5000,      // Connection timeout in ms (default: 5000)
            },
          ],
          event: emitter,         // Optional custom EventEmitter
        };
      },
    }),
  ],
})
export class AppModule {}

Controller Integration

There are two main ways to handle OpenVPN events in NestJS:

  1. Using decorators
  2. Using EventEmitter callbacks

Both are valid; decorators provide a clean declarative style, while direct emitter usage offers more flexibility and type inference.

1. Decorator approach

Full example: examples/decorator

@Injectable()
export class OpenvpnController {
  private readonly logger = new Logger(OpenvpnController.name);

  constructor(
    @Inject() private readonly openvpnService: OpenvpnService,
  ) {
    registerOpenvpnListeners(this, this.openvpnService.emitter);
  }

  @OpenvpnEvent("client:list", { once: true })
  handleClientList(client: Cl[]) {
    this.logger.log(`Client connected: ${client[0].clientID}`);
  }

  @OpenvpnEvent("client:connection")
  handleClientConnect(client: ConnectionClient) {
    this.logger.log(`Client connected: ${client.n_clients}`);
  }

  @OpenvpnEvent("client:disconnect")
  handleClientDisconnect(client: string[]) {
    this.logger.warn(`Client disconnected: ${client[0]}`);
  }
}

The registerOpenvpnListeners() function automatically registers all class methods marked with @OpenvpnEvent.
You can use the built-in NestJS Logger or inject your own custom logger if needed. Passing OpenvpnService is optional — if you have your own event emitter, just pass it manually.

2. Event-driven approach

Full example: examples/emitter

@Injectable()
export class ExternalService implements OnApplicationBootstrap {
  constructor(
    @Inject() private readonly openvpnService: OpenvpnService,
    @Inject() private readonly logger: Logger,
  ) {}

  onApplicationBootstrap() {
    const emitter = this.openvpnService.emitter;

    emitter.on("client:connection", async (clientList) => {
      // handle client connection
    });

    emitter.on("client:disconnect", async (client) => {
      // handle client disconnect
    });

    emitter.once("client:list", async (clients) => {
      for (const { commonName, virtualAddress } of clients) {
        // handle client info
      }
    });
  }
}

Additional Information

You can find all available types and methods in the main openvpn-manager repository.