Skip to content

⛽️ Additional utility functions for slack like creating different type of messages!

Notifications You must be signed in to change notification settings

GoApptiv/slack-helper-nestjs-package

Repository files navigation

GoApptiv Slack Helper NestJS

This package provides additional utility functions for Slack like automatically sending exception message to slack on exception and many more features to come

Installation

  1. Create a .npmrc in the root folder and add the following lines.
//npm.pkg.github.com/:_authToken=TOKEN
@goapptiv:registry=https://npm.pkg.github.com/
  1. Create a personal token with read:packages permission and replace the TOKEN with your personal token in the above mentioned file.

  2. Install the package using the following command

npm install @goapptiv/slack-helper-nestjs
  1. Register the SlackHelperModule in your root module
SlackHelperModule.registerAsync({
  isGlobal: true,
  imports: [AppConfigModule],
  useFactory: (appConfigService: AppConfigService) => ({
    appEnv: appConfigService.appEnvironment,
    channels: {
      default: 'general',
      general: 'general',
      exceptions: 'exception',
    },
  }),
  inject: [AppConfigService],
});
  1. Pass eventEmitter

This package internally uses @goapptiv/exception-handler-nestjs, so make sure to pass the eventEmitter to exception-handler filters.

Usage

It does everything automatically!

Troubleshooting

1) ERROR [ExceptionHandler] Nest can't resolve dependencies of the SlackService (?, SlackWebClient, SlackGoogleLogging). Please make sure that the argument SlackModuleOptions at index [0] is available in the SlackHelperModule context.

Solution: Make you have made the SlackModule (provided by nestjs-slack) as Global.