
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@algoan/nestjs-google-pubsub-microservice
Advanced tools
A GooglePubSub transport strategy with NestJS Microservice
A Nest Google PubSub Microservice.
A custom NestJS Microservice transport strategy using Google Cloud PubSub.
npm install --save @algoan/pubsub @algoan/nestjs-google-pubsub-microservice
To start a new Google Cloud PubSub server:
Server setup:
// main.ts
import { GooglePubSubOptions } from '@algoan/pubsub';
import { INestMicroservice } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { GCPubSubServer } from '@algoan/nestjs-google-pubsub-microservice';
import { AppModule } from './app.module';
async function bootstrap() {
const options: GooglePubSubOptions = {
projectId: 'test',
subscriptionsPrefix: 'test-app',
}
const app: INestMicroservice = await NestFactory.createMicroservice(AppModule, {
strategy: new GCPubSubServer(options)
})
await app.listen();
console.log('Server running!')
}
bootstrap()
Controller:
import { EmittedMessage } from '@algoan/pubsub';
import { Controller } from '@nestjs/common';
import { EventPattern, Payload } from '@nestjs/microservices';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
/**
* Handle the test event
* @param data Payload sent
*/
@EventPattern('test_event')
public async handleTestEvent(@Payload() data: EmittedMessage<{ hello: string }>): Promise<void> {
/**
* Handle data emitted by Google PubSub
*/
this.appService.handleTestEvent(data);
}
}
You can add ListenOptions
to the subscription by adding extras
to the EventPattern
decorator. For example, if you want a different topic name:
/**
* Handle the test event
* @param data Payload sent
*/
@EventPattern('test_event', { topicName: 'different_topic' })
public async handleTestEvent(@Payload() data: EmittedMessage<{ hello: string }>): Promise<void> {
/**
* Handle data emitted by Google PubSub
*/
this.appService.handleTestEvent(data);
}
When the application will start and look for event patterns, it will get or create the different_topic
topic from Google Cloud.
This module uses @algoan/pubsub library which by default automatically acknowledges emitted messages.
GCPubSubServer(options)
Create a new Server instance of Google PubSub. It retrieves all message handlers patterns and creates subscriptions.
options
: Algoan PubSub options. More information here.options.listenOptions
: Global options which will be applied to all subscriptions.options.topicsNames
: Only subscribe to topics included in this whitelist.Other modules implementing Google Cloud PubSub with NestJS microservices:
FAQs
A GooglePubSub transport strategy with NestJS Microservice
The npm package @algoan/nestjs-google-pubsub-microservice receives a total of 0 weekly downloads. As such, @algoan/nestjs-google-pubsub-microservice popularity was classified as not popular.
We found that @algoan/nestjs-google-pubsub-microservice demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.