0.2.5 • Published 5 years ago

@wemaintain/slack v0.2.5

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
5 years ago

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
  }
}
0.2.3

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.0

5 years ago

0.2.1

5 years ago