@wemaintain/slack
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

Nest Logo      Nest Logo

@wemaintain/slack

Slack module for Nest

Installation

  1. Install the required packages
    npm install --save @wemaintain/slack @slack/web-api @slack/events-api
  2. Import the SlackModule in your Module, ideally in the root module
@Module({
  imports: [
    SlackModule
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

Configuration

Configuration of the module can be acheived by using the forRoot and forRootAsync method

forRoot:

@Module({
  imports: [
    SlackModule.forRoot({
      signingSecret: process.env.SLACK_SIGNING_SECRET
    })
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

forRootAsync:

@Module({
  imports: [
    ConfigModule,
    SlackModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (option) => option.slack
    })
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

SlackClient: WebClient API

The SlackClient is a wrapper the WebClient Slack API Inject it inside your component like any other Provider:

  constructor(
    protected readonly slackService: SlackClient,
  ){}

SlackEvent: Event API

The SlackEventService is a service that listen for the Event Slack API

If the signingSecret is provided to the SlackModule it will look for @SlackEvent decorator in your controllers And bind them to the webhook listener

@Controller()
export class AppController {

  @SlackEvent('message')
  onMessageInChannel(): void {
    // Do thing
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @wemaintain/slack

Weekly Downloads

0

Version

0.2.5

License

Apache-2.0

Unpacked Size

34.9 kB

Total Files

26

Last publish

Collaborators