Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/the-software-compagny/nestjs_module_twurple

Twitch API/Chat/PubSub with Twurple NestJS module
https://github.com/the-software-compagny/nestjs_module_twurple

abstract abstraction api async chat nestjs node nodejs npm promise pubsub spaces twitch twurple

Last synced: 15 days ago
JSON representation

Twitch API/Chat/PubSub with Twurple NestJS module

Awesome Lists containing this project

README

        



Nest Logo


Twitch API/Chat/PubSub with Twurple NestJS module


NPM Version
Package License
Publish Package to npmjs



# Twurple Module
Twurple for NestJS Framework

## Install dependencies
```bash
yarn add @the-software-compagny/nestjs_module_twurple
```
## Instanciate
```ts
// app.module.ts
import { TwurpleModule, TwurpleOptions } from '@the-software-compagny/nestjs_module_twurple'

TwurpleModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
config: config.get('twurple.options'),
}),
})
```
## Usage
```ts
// twitch.service.ts
import { FactorydriveService } from '@the-software-compagny/nestjs_module_factorydrive'

@Injectable()
export class FileStorageService {
public constructor(
@InjectTwurpleApi() private readonly twurpleApi: ApiClient,
@InjectTwurpleChat() private readonly twurpleChat: ChatClient,
@InjectTwurplePubsub() private readonly twurplePubSub: PubSubClient,
) {
// ...

this.twurpleChat.onMessage(async (channel, user, message) => {
if (message === '!ping') {
this.twurpleChat.say(channel, 'Pong!')
}
})

// ...
}
}
```