# @algoan/nestjs-google-pubsub-client

> A NestJS ClientProxy for Google Cloud PubSub

Latest version **0.5.0** (published 2026-09-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install @algoan/nestjs-google-pubsub-client
pnpm add @algoan/nestjs-google-pubsub-client
yarn add @algoan/nestjs-google-pubsub-client
bun add @algoan/nestjs-google-pubsub-client
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2026-09-24 |
| First published | 2020-04-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 247 |
| Author | ccoeurderoy |
| Maintainers | algoanbot, fabong |
| Keywords | nestjs, nodejs, typescript, google-cloud-pubsub |

## Links

- npm: https://www.npmjs.com/package/@algoan/nestjs-google-pubsub-client
- Repository: https://github.com/algoan/nestjs-components
- Homepage: https://github.com/algoan/nestjs-components/tree/master/packages/google-pubsub-client#readme
- Issues: https://github.com/algoan/nestjs-components/issues
- npm.io page: https://npm.io/package/@algoan/nestjs-google-pubsub-client

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2026-09-24
- 0.4.13 — 2025-06-11
- 0.4.12 — 2024-09-16
- 0.4.11 — 2023-12-11
- 0.4.10 — 2023-11-10
- 0.4.9 — 2023-06-17
- 0.4.8 — 2023-02-24
- 0.4.7 — 2023-02-02
- 0.4.6 — 2023-01-31
- 0.4.5 — 2022-11-19
- 0.4.4 — 2022-11-19
- 0.4.3 — 2022-07-26
- 0.4.2 — 2022-05-19
- 0.4.1 — 2022-01-07
- 0.4.0 — 2021-11-16
- … 19 more at https://npm.io/package/@algoan/nestjs-google-pubsub-client/versions

## README

# `google-pubsub-client`

The client extends the ClientProxy class and  have to override the emit method using @algoan/pubsub.

⚠️ **This Client only overrides the [abstract `dispatchEvent` method](https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-proxy.ts#L80). Therefore, only the `client#emit` method can be called.**

## Installation

```bash
npm install --save @algoan/pubsub @algoan/nestjs-google-pubsub-client
```

## Usage

To instantiate the GCPubSubClient:


**Module**:

```ts
// app.module.ts
import { Module } from '@nestjs/common';

import { GCPubSubClient } from '../../src';
import { AppController } from './app.controller';
import { AppService } from './app.service';

/**
 * App module
 */
@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'PUBSUB_CLIENT',
      useFactory: () => {
        // Use a factory to add you custom options
        return new GCPubSubClient({});
      },
    },
  ],
})
export class AppModule {}

```

**Service**:

```typescript
import { Inject, OnModuleInit } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';

/**
 * Fake app service
 */
export class AppService implements OnModuleInit {
  constructor(@Inject('PUBSUB_CLIENT') private readonly client: ClientProxy) {}

  /**
   * Connect the client proxy on module init
   * NOTE: this is optional with GooglePubSubClient. It is called anyway in the emit method
   * See https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-proxy.ts#L67
   */
  public async onModuleInit(): Promise<void> {
    await this.client.connect();
  }
  /**
   * Emit a test event
   * @param data Payload sent
   */
  public emitTestEvent(data: { hello: string }): void {
    this.client.emit('test_event', data);
  }
}
```

### `new GCPubSubClient(options)`

Initiate a new Google Cloud PubSub Client proxy.

- `options`: Options related to the GC PubSub instance. More details on options [here](https://github.com/algoan/pubsub#pubsubfactorycreate-transport-options-)

---
_Source: https://npm.io/package/@algoan/nestjs-google-pubsub-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
