Sending Slack alerts from NestJS
npm install @n4it/utility-slack-alerts``bash`
npm install @n4it/utility-slack-alerts
, import it into your NestJS module and configure it using the register method.`typescript
import { SlackAlertsModule } from "@n4it/utility-slack-alerts";
import { Module } from "@nestjs/common";@Module({
imports: [
SlackAlertsModule.register({
url: "https://hooks.slack.com/services/XXXXXXX/XXXXXX/XXXXXX"
}),
],
})
export class AppModule {}
`You can now use it:
`typescript
import { SlackAlertService } from "@n4it/utility-slack-alerts";
import { Injectable } from "@nestjs/common";@Injectable()
export class AppService {
constructor(private readonly alertService: SlackAlertService) {}
public send() {
return this.alertService.sendErrorAlert({
message: "My foo error",
})
}
}
``