New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@e3o/pubsub

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@e3o/pubsub

PubSub connector

latest
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

pubsub

How to install

  • In your package.json file, add @e3o/pubsub in your dependencies followed by the version number or run
npm install @e3o/pubsub
  • Import the PubSubModule in your AppModule and pubsub subscriptions
import { PubSubModule } from '@e3o/pubsub'
import { subscriptions } from './../automation/pubsub/conf-topic-subscription.json'
  • Register the module
@Module({
  imports: [
    PubSubModule.register({
      projectId: config.get('PUBSUB_PROJECT_ID'),
      keyFilename: config.get('PUBSUB_KEY_FILENAME'),
      origin: config.get('PUBSUB_ORIGIN'),
      prefix: config.get('PUBSUB_PREFIX'),
      subscriptions,
      listenOnStartUp, //boolean : start immediatly pulling (used for blue/green)
    }),
  ],
  • Start the microservice in main.ts
import { PubSubServer } from '@e3o/pubsub'

async function bootstrap() {
  const app = await NestFactory.create(AppModule)
   // Start PubSub microservice
  app.connectMicroservice({ strategy: app.get(PubSubServer) })
  await app.startAllMicroservicesAsync()
  ...

Usage

  • Listening to topics (using EventPattern decorator)
  @EventPattern('MESSAGE_KEY')
  handleDeliveyInit(message: any): void {
    ...
  }
  • Sending message to topics
  constructor(
    @Inject(PUBSUB_CLIENT) private readonly client: ClientProxy,
  ) {}

  public test() {
    this.client.emit('MESSAGE_KEY', { message : "test"})
  }

FAQs

Package last updated on 28 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts