Skip to content

Commit

Permalink
feat: add twitch message version
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicToast committed Sep 27, 2024
1 parent e65bd68 commit a4f4e01
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions apps/azkaban-gateway/src/app/core/twitch-message-service.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Module } from '@nestjs/common';
import { ClientsModule } from '@nestjs/microservices';
import {
clientProvider,
twitch_messages,
twitch_vhost,
} from '@toxictoast/azkaban-broker-rabbitmq';
import { brokerDefaultSettings } from './broker-defaults';

@Module({
imports: [
ClientsModule.register([
{
name: 'TWITCH_MESSAGE_SERVICE',
...clientProvider({
queueName: twitch_messages,
brokerVHost: twitch_vhost,
...brokerDefaultSettings,
}),
},
]),
],
exports: [ClientsModule],
})
export class TwitchMessageServiceModule {}
12 changes: 12 additions & 0 deletions apps/azkaban-gateway/src/app/version/twitch-versions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TwitchBotTopics,
RmqRecordBuilderHelper,
TwitchViewerTopics,
TwitchMessageTopics,
} from '@toxictoast/azkaban-broker-rabbitmq';

@Injectable()
Expand All @@ -12,6 +13,8 @@ export class TwitchVersionsService {
@Inject('TWITCH_BOT_SERVICE') private readonly botClient: ClientProxy,
@Inject('TWITCH_VIEWER_SERVICE')
private readonly viewerClient: ClientProxy,
@Inject('TWITCH_MESSAGE_SERVICE')
private readonly messageClient: ClientProxy,
) {}

private async getBotVersion() {
Expand All @@ -28,13 +31,22 @@ export class TwitchVersionsService {
.toPromise();
}

private async getMessageVersion() {
const payload = RmqRecordBuilderHelper({});
return await this.messageClient
.send(TwitchMessageTopics.VERSION, payload)
.toPromise();
}

async getTwitchVersions() {
const bot = await this.getBotVersion();
const viewer = await this.getViewerVersion();
const message = await this.getMessageVersion();
//
return {
bot,
viewer,
message,
};
}
}
2 changes: 2 additions & 0 deletions apps/azkaban-gateway/src/app/version/version.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { AzkabanVersionsService } from './azkaban-versions.service';
import { TwitchBotServiceModule } from '../core/twitch-bot-service.module';
import { TwitchVersionsService } from './twitch-versions.service';
import { TwitchViewerServiceModule } from '../core/twitch-viewer-service.module';
import { TwitchMessageServiceModule } from '../core/twitch-message-service.module';

@Module({
imports: [
Expand Down Expand Up @@ -55,6 +56,7 @@ import { TwitchViewerServiceModule } from '../core/twitch-viewer-service.module'
// Twitch Services
TwitchBotServiceModule,
TwitchViewerServiceModule,
TwitchMessageServiceModule,
],
controllers: [VersionController],
providers: [
Expand Down

0 comments on commit a4f4e01

Please sign in to comment.