@anchan828/nest-cloud-run-queue-tasks-publisher
Install
npm i @anchan828/nest-cloud-run-queue-tasks-publisher
Usage
NOTE: You may want to do tutorial for using Tasks with Cloud Run before using them.
https://cloud.google.com/run/docs/triggering/using-tasks
Import publisher module
@Module({
imports: [
TasksPublisherModule.register({
clientConfig: {
projectId: "projectId",
keyFilename: "path/to/file.json",
},
publishConfig: {
httpRequest: {
url: "https://example-this-is-demo-uc.a.run.app",
},
},
queue: "projects/test/locations/location/queues/nest-cloud-run-queue-demo",
}),
],
})
export class PublisherAppModule {}
Publish message to queue
export class Service {
constructor(private readonly tasksService: TasksPublisherService) {}
public async sendMessage(): Promise<void> {
await this.tasksService.publish({
name: "Worker name",
data: "text",
});
}
}
See more information: https://github.com/anchan828/nest-cloud-run-queue#readme