Event Decorator

Event Decorator#

This decorator defines the event name, but it requires the usage of channel decorator in order to know where it should be sent to or to whom

Basic example#

import { Controller, Get } from '@nestjs/common';
import { PusherChannel, PusherEvent } from 'nestjs-pusher';
@Controller('cats')
export class CatsController {
constructor(private readonly catService: CatService) {
//Imaginary service for the sake of the example
}
@PusherChannel('private-channels-of-cats')
@PusherEvent('cat.created')
@Post()
async createCat(@Body() dto): string {
const newCat = await this.catService.create(dto)
//The return value will be used as the content
return newCat
}
}